View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default When is a Loop Necessary ?

Thank you!
--
Gary''s Student - gsnu200747


"Joel" wrote:

You only need to loop when you have to test values in each cell for some
condition.



"Gary''s Student" wrote:

When is it necessary to loop over the cells in a range as opposed to setting
some property of the entire range at once. For example:

Sub loop_test()
Dim rr As Range, r As Range
Set rr = Range("A1,C10,D12")
For Each r In rr
r.Value = r.Address
Next
End Sub


can be accomplished with:

Sub loop_test2()
Dim rr As Range
Set rr = Range("A1,C10,D12")
rr.Value = rr.Address
End Sub
--
Gary''s Student - gsnu200747