0

When I run this code I manage to fill the table that I want to, but in the last iteration it breaks on the Range("F" & r)... line and gives the error1004. I don't see why. Indeed running it works... but yields the error at the end.

Sub Stuff1()
    Dim r As Integer
    r = 37
    Do
        Range("F" & r).GoalSeek Goal:=0, ChangingCell:=Range("D" & r)
        r = r + 1
    Loop Until IsEmpty("E" & r)
End Sub

Note: I tried doing a Do While Not and it happens exactly the same. Edit: Excel 2013 btw

4

2 回答 2

2

您需要更改IsEmpty函数以引用 a Rangenot a string,就像它目前正在做的那样。

Loop Until IsEmpty(Range("E" & r))

此外,您应该将数据类型更改rLong。如果您尝试访问第 32768 行或之后的行,您将使用Integer.

关于您的 1004 错误...

目标搜索单元格必须具有引用您要操作的单元格的公式。我怀疑这将是您错误的原因。

于 2013-11-09T17:49:24.753 回答
1
Loop Until Range("E" & r)=""
于 2013-11-09T15:37:45.260 回答