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'并找出你在哪里想要把第二个值 –
谢谢你...它当然可以 –