0

I have a spread sheet where all of column A is a named range called "Michael".

I am getting the row number of the last occupied row.

This code works: LRow = Worksheets("Head").Range("A" & Rows.Count).End(xlUp).Row

This code does not work: LRow = Worksheets("Head").Range("Michael" & Rows.Count).End(xlUp).Row

How do I get this to work with me using the column name "Michael" and not the default A?

0

2 Answers 2

4

You would refer to the column and row count of the range inside Cells() range object:

LRow = Cells(Range("micheal").Rows.count, Range("micheal").Column).End(xlUp).Row
Sign up to request clarification or add additional context in comments.

Comments

0

Using Find is recommended rather than xlUp. Both approaches shown below

Dim rng1 As Range
Dim lRow As Long

'Option 1
lRow = Cells(Rows.Count, Range("Michael").Column).End(xlUp).Row

'Option 2
Set rng1 = Range("Michael").Find("*", Range("Michael")(1), , , xlPrevious)
If Not rng1 Is Nothing Then MsgBox rng1.Row

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.