我正在尝试查找给定列表的值并将剩余的行内容复制到与列表相邻的列中。我从这个网站复制了一些代码,并在其他地方寻找答案,找不到任何东西。每次我运行代码时,它都会给我一个编译错误“无效的外部程序”
Sub test()
Dim LR As Long
Dim i As Long
Dim x As Long
Dim lastDataRow As Long
Dim lastListRow As Long
Dim sheetOne As String
Dim sheetTwo As String
Dim listItem As String
Dim dataItem As String
Dim listColNum As Long
Dim dataColNum As Long
listColNum = 1
dataColNum = 2
sheetOne = "new_copy"
sheetTwo = "Historical_data_"
lastListRow = Sheets(sheetOne).Cells(Sheets(sheetOne).Rows.Count, listColNum).End(xlUp).row
lastDataRow = Sheets(sheetTwo).Cells(Sheets(sheetTwo).Rows.Count, dataColNum).End(xlUp).row
For x = 1 To lastListRow
For i = 1 To lastDataRow
If Sheets(sheetOne).Cells(x, listColNum).Value = Sheets(sheetTwo).Cells(i, dataColNum).Value Then
Sheets(sheetOne).Cells(x, 3).Value = Sheets(sheetTwo).Cells(i, 3).Value
End If
Next i
Next x
End Sub
任何帮助,将不胜感激!