简体   繁体   English

工作表的方法单元格对象失败

[英]Method Cells object of Worksheet failed

My code throws the following error: 我的代码抛出以下错误:

run time error -2147417748(80010108) Method Cells of Object Worksheet failed 运行时错误-2147417748(80010108)对象工作表的方法单元格失败

After it has traversed the counter2 loop 7 times on the 8th iteration of the outer loop it throws the error. 在外部循环的第8次迭代中遍历counter2循环7次后,将引发错误。 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! 不管怎么说,还是要谢谢你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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