標題:
[發問]
根據目前字串到其他工作頁搜尋字串並填回值
[打印本頁]
作者:
a703130
時間:
2012-3-15 18:41
標題:
根據目前字串到其他工作頁搜尋字串並填回值
小弟現有個檔案要請前輩們幫忙
需要求得附件的get
[attach]10000[/attach]
當我在 sheet("1")的 Index 看到有數字時他便會到 Name 去抓字串
之後到 sheet("a") 的欄位中找到一樣的字串後填入 sheet("1") 的get 欄位
但是要照順序填入若遇到 一 則跳過
例如:
index 找到 1 對照到 a_tool1 之後到 sheet("a") 找到 tool1
在Sheet("1") 的 get 欄位填入:1,2,3,4,5,6,7,8,,,,,11,12,13
我目前想到的方式
Dim S As Integer
Dim get As String
If FlagIndex = "有值" Then
S = Name - Mainpage - "_"
get =GetS (S)
Else
Status = ""
End IF
Function GetS(Byval s As String) As String
判斷sheet("a") 是否有 S 字串
End Function
複製代碼
不知道前輩們是否有解??
作者:
Hsieh
時間:
2012-3-15 19:52
回復
1#
a703130
Sub ex()
Set d = CreateObject("Scripting.Dictionary")
For Each sh In Sheets
d(sh.Name) = d.Count
Next
With Sheet1
For Each a In .Range("F:F").SpecialCells(xlCellTypeConstants, xlNumbers)
If d.exists(a.Offset(, -4).Text) Then
With Sheets(a.Offset(, -4).Text)
Set c = .Columns("A").Find(Split(a.Offset(, -5), "_")(1), lookat:=xlWhole)
If Not c Is Nothing Then
i = 1
k = Application.Count(c.Offset(1, 2).Resize(2, 8))
For x = 2 To 1 Step -1
For y = 8 To 1 Step -1
b = c.Offset(1, 2).Resize(2, 8).Cells(x, y)
If IsNumeric(b) Then
mystr = IIf(mystr = "", Application.Small(c.Offset(1, 2).Resize(2, 1).EntireRow, i), mystr & "," & Application.Small(c.Offset(1, 2).Resize(2, 1).EntireRow, i))
i = i + 1
Else
mystr = IIf(mystr = "", "", mystr & ",")
End If
Next
Next
a.Offset(, 1) = mystr
mystr = ""
End If
End With
Else
a.Offset(, 1) = ""
End If
Next
End With
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)