运行我的 VBA 代码时遇到了一个小问题。我正在尝试检索和检查 excel 中指定列中的信息。它将运行 16 次以检索信息,直到第 17 次它甚至没有给我工作簿中列中的内容。你能帮助或指导我解决问题吗?
Dim CheckingWhatsInCell As String
Dim i As Integer
Dim j As Integer
Dim ToWorkbook As Workbook
ThisWorkbook.Activate
For i = 1 To 20
CheckingWhatsInCell = Trim(Range("K" & i).Value)
If CheckingWhatsInCell = "Albuquerque NM" Then
Set ToWorkbook = Workbooks.Open("C:\Users\mgonza-c\Documents\TerritoryAlbuquerqueNM.xlsx")
For j = 1 To 139
ToWorkbook.Worksheets("Sheet1").Cells(i, j) = ThisWorkbook.Sheets("Sheet2").Cells(i, j).Value
Next j
End If
Next i
ToWorkbook.Save
ToWorkbook.Close
End Sub
谢谢!