row number within a named range

  • Thread starter Thread starter Werner Rohrmoser
  • Start date Start date
W

Werner Rohrmoser

Hello,

I have a named range called "Versions" and it's located in "A10:A15".
When I select Range "A12" I get 12, when I use ActiveCell.Row.
What I'd like to know is the relative row in Range "Versions", which
would be 3.

What' s the syntax for it?
Thanks.

Regards
Werner

Excel XP SP3
Win XP SP1
 
Sub marine()
MsgBox (ActiveCell.Row - Range("Versions").Row + 1)
End Sub
 
I would check the active cell is in the named range first

Sub sonic()
If Intersect(ActiveCell, Range("versions")) Is Nothing Then
MsgBox "The selected cell is not in the named range"
Else
With Range("versions")
irownumber = .Row
End With
MsgBox ActiveCell.Row - irownumber+1
End If
End Sub


Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top