Jing He
Jing He

Reputation: 914

How to get the row number of the last row of a range in Exce VBA?

Is there any method or property by which I can get the row number of last row in a range no matter if that row is totally empty? like

Range("A2:B4").Rows.Lastrow

will return "4" even the row 4 is totally empty.

Upvotes: 1

Views: 791

Answers (3)

Hadi
Hadi

Reputation: 184

Another option that returns the row number for a range

Split(MyRange.Rows.Address, "$")(4)

Hope this helps

Upvotes: 1

user6698332
user6698332

Reputation: 427

Iterate Selection.Areas to find a bottom row in case of multiple selection and use the method toy posted above.

Upvotes: 1

Jing He
Jing He

Reputation: 914

Range("A2:B4").Row + Range("A2:B4").rows.count -1

Upvotes: 1

Related Questions