Excel vba - get the row number

I have code as follows:

Dim rRepCell As Variant
Dim rRepRow As Integer

Application.Goto Reference:="Reps" ' an existing range
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.End(xlDown).Select
rRepCell = ActiveCell.Address(0, 0)
rRepRow = Selection.Row(rRepCell)

Getting an error on the line:

rRepRow = Selection.Row(rRepCell)

Runtime error 451. Property let procedure not defined and property get procedure did not return an object.

What I want is the row number at the bottom of the range.

What is wrong? 

Thanks for the assist.

Answer
Answer

Hi,

This can all be done without selecting anything like this

Dim rRepRow As Long
Dim rRepCell As String
rRepRow = Range("Reps").Offset(1, 1).End(xlDown).Row

rRepCell = Range("Reps").Offset(1, 1).End(xlDown).Address(0, 0)

If this response answers your question then please mark as answer.

Mike H

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

How about

rRepRow = Range("Reps").Cells(1, 1).Offset(1, 1).End(xlDown).Row

---
Best wishes, HansV
https://www.eileenslounge.com

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 923 Applies to: