|
本帖最后由 huangyerong 于 2019-10-25 11:40 编辑
表格“测试用”宏已经设置好,但是目前取数只能取到第一行数据,我想实现取数取到第一行到第十行,请教高手,万分感谢!
Sub 回款取数()
Dim pro As String, i As Long, j As Long, x As Long, y As Long, path As String, xmpath As String
Dim fs, f, f1, fc
i = 1
xmpath = "测试用"
path = ThisWorkbook.path & "\" & xmpath & "\"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(path)
Set fc = f.Files
Do While i <= 500
pro = ActiveSheet.Cells(i, 1)
If pro <> "" Then
For Each f1 In fc
If (InStr(1, f1.Name, pro) <> 0) Then
For j = 2 To 10
ActiveSheet.Cells(i, j) = "='" & path & "[" & f1.Name & "]春风十里'" & "!R" & 1 + x & "C" & -1 + j
Next j
End If
Next f1
End If
i = i + 1
Loop
MsgBox "取数完成"
End Sub
|
|