refer to cell in range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi! i have a named range. in a loop i want to loop through the different
cells in the range. i do not know how to do this. My named range:

Dim varCounterpartyData As Variant
varCounterpartyData =
ThisWorkbook.Sheets("Counterparty").Range("CounterpartyIndataRange").Value

but how do i refer to the first cell in the range? or rather the value that
is in the first cell. any help much appreciated!
 
Arne,
One way:

Dim Cell as range

for each cell in Range("YourName")
debug.print cell.address
next

And the first cell:
MsgBox Range("YourName")(1).Value
MsgBox Range("YourName").Cells(1, 1).Value

Qualify the above ranges as required.

NickHK
 
Try this. I've assumed you named your range on the worksheet and don't want
to define it at VBA level.


Sub marine()
Dim varCounterpartyData As Range
For Each c In Range("varCounterpartyData")
MsgBox (c.Value)
Next c

End Sub

Mike
 
Back
Top