0
我對這個代碼的工作如下如何獲得多個值(如何獲得第二匹配數據)
我試圖從另一個工作簿中的數據工作表Sheet1 我的問題是有兩個」金融深化」以不同的價值工作表Sheet1工作簿如何 我可以讓他們兩種不同的細胞
例如
金融深度= 10.000
金融深度= 24.000
此代碼獲取第一個值。(金融深度= 10.000)......
Sub Balance()
Dim I As Integer
Dim myfile As String
Pathname = 「E:\test\」
I = 1
myfile = Dir(Pathname & 「*.xls」)
Cells(1, I) = myfile
StartingPoint:
I = I + 1
myfile = Dir
Cells(I, 1) = myfile
If myfile 「」 Then GoTo StartingPoint
I = I – 1
For K = 1 To I
‘On Error Resume Next
‘ *** workbook name***
Filename = Cells(K, 1)
Workbooks.Open (Pathname & Filename)
‘ *** company name ***
Cells(K, 2) = Workbooks(Filename).Worksheets(「Sheet1″).Cells(1, 1)
‘ *** Financial Depth***
Cells(K, 3) = 」 Financial Depth」
For g = 1 To 220
If Workbooks(Filename).Worksheets(「Sheet1″).Cells(g, 1) = 」 Financial Depth」 Then
Cells(K, 4) = Workbooks(Filename).Worksheets(「Sheet1″).Cells(g, 3)
Exit For
End If
Next g
Workbooks(Filename).Saved = True
Workbooks(Filename).Close
Next k
End Sub
刪除'退出For'並找出你在哪裏想要把第二個值 –
謝謝你...它當然可以 –