简体   繁体   中英

Method Cells object of Worksheet failed

My code throws the following error:

run time error -2147417748(80010108) Method Cells of Object Worksheet failed

After it has traversed the counter2 loop 7 times on the 8th iteration of the outer loop it throws the error. This is strange given that the same loop on the same data is running properly in the same macro just before this piece of code:

Do While Worksheets("Sheet1").Cells(counter2, 1).Value <> ""
    If (Worksheets("Sheet1").Cells(counter2, categoryPoint).Value = _
        Worksheets("Sheet5").Cells(counter, 4).Value) _
        And (Worksheets("Sheet1").Cells(counter2, subCategoryPoint).Value = _
        Worksheets("Sheet5").Cells(counter, 5).Value) Then

        Do While counter3 <> attrCount + 1
            If Worksheets("Sheet1").Cells(counter2, counter3).Value = "" Then gold = gold + 1
             counter3 = counter3 + 1
        Loop
        counter2 = counter2 + 1
        counter3 = 1
    End If
Loop

Never mind it was a silly error where the loop was infinite. Wonder why it threw a weird error. Thanks anyway!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM