0
運行我的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
謝謝!
我沒有看到任何會導致錯誤的代碼錯誤。很可能您在K17中導致錯誤的數據無效。 – Pynner
嘿Pynner!感謝您的回覆。你什麼意思是無效數據?像細胞格式? – Michelle
單元格K17是否有像#DIV!0或#N/A或#VALUE等錯誤? 對於i = 17,CheckingWhatsIncell的vlaue是什麼? –