View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mark Mark is offline
external usenet poster
 
Posts: 102
Default Determine the text in a range that covers several cells


Try this out:


Sub RangeTest()

Dim CurRng As Range
Dim CellRng As Range

Application.ScreenUpdating = False
Set CurRng = Range("A1:A3")
CurRng = "Anderson"
For Each CellRng In CurRng
MsgBox "Range (" & CellRng.Address & ") CurRng now contains the
value: " & CellRng
Next CellRng
Application.ScreenUpdating = True

End Sub

I think what is throwing you is that when you define a range that has
more than one cell in it, you are trying to ask the computer for the
value of the range as a whole. this cannot be done. You have to
iterate through each member of the range and get it's individual
contents. That is what the For/Next loop does in the routine above.
Hope that is more helpful.