C
curiousgeorge408
Sigh, I always seem to have trouble gronking VBA syntax and
semantics. I am sure I have seen examples of the following before,
even in my reference book. But I cannot find them now.
I would like to write something like:
Sub doit()
Dim rng As Range
rng = Range("A1:B4")
For i = 1 To rng.Count: Debug.Print rng.Cells(i): Next i
End Sub
That works if I comment out "rng=..." and replace "rng" with Range
("A1:B4") everywhere. But I get a runtime error on the assignment
statement ("object variable not set").
PS: The above is a distillation of a larger problem. Please do not
offer alternatives to programming the algorithm. I am trying to
understand a language concept, not a programming concept.
semantics. I am sure I have seen examples of the following before,
even in my reference book. But I cannot find them now.
I would like to write something like:
Sub doit()
Dim rng As Range
rng = Range("A1:B4")
For i = 1 To rng.Count: Debug.Print rng.Cells(i): Next i
End Sub
That works if I comment out "rng=..." and replace "rng" with Range
("A1:B4") everywhere. But I get a runtime error on the assignment
statement ("object variable not set").
PS: The above is a distillation of a larger problem. Please do not
offer alternatives to programming the algorithm. I am trying to
understand a language concept, not a programming concept.