我想循环遍历文件excel中的列,而不仅仅是列A,但我没有成功。你能帮帮我吗? 它是我阻止的7行(Filepath)。如果我为icol更改了A列,它就不起作用了。
Set workboo = Workbooks.OpeN("C:\Users\Desktop\list_files.xlsx")
Set worksh = workboo.Worksheets("List_File")
For j = 1 To 10
icol = 2 * j - 1
numRows = worksh.Cells(Application.Rows.Count, icol).End(xlUp).Row
For i = 2 To numRows
Filepath = worksh.Range("A" & i).Value 'i changed column A for icol but it doesn t work
fso.CopyFile Filepath, Destination, True
Next
答案 0 :(得分:0)
要遍历列,它将更容易使用Cells
:
Filepath = worksh.Cells(i, icol).Value
而且:
numRows = worksh.Cells(Application.Rows.Count, icol).End(xlUp).Row
应该是
numRows = worksh.Cells(worksh.Rows.Count, icol).End(xlUp).Row