# Lookup last valid row

#### grahambza

##### New Member
Hi
I have a list of approx 130 suppliers that I want to use as my list for a drop down box
In my range for the drop down I make the range bigger in case I add suppliers

What I want to do is
- have a formula work out which is the last valid row
- use this cell ref in my sort and range formulas

Any tips?

Graham

### Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

#### grahambza

##### New Member
I used countif(A1:A200,"*") to get the answer

How do i use this result in a sort macro

Currently my macro contains
"=Sheet3!R1C1:R200C1"

Any help is appreciated

#### VoG

##### Legend
Do you mean that you need VBA to return the last filled row in column A? If so

Code:
``````Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row``````

#### davesweep

##### Well-known Member

Hi,

Create a named range. If your data is in column A for example, use
=OFFSET(\$A\$1,0,0,1,COUNTA(Sheet1!A:A))
then use the range name as the definition for your validation list.

#### grahambza

##### New Member
Thanks everyone

How do I use the result of the Last Row in a formula?

I tried this:

Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row

Range("A1:LR").Select
"=Sheet3!R1C1:LRC1"
'"=Sheet3!R1C1:R200C1"

And of course I got an error in the range selection

Any help is appreciated

#### grahambza

##### New Member

I worked out how to use the offset suggested by VOG II - and now have another problem which i will post separately

#### VoG

##### Legend
Try this

Code:
``````Sub test()
Dim LR As Long
With Sheets("Sheet1")
LR = .Range("A" & Rows.Count).End(xlUp).Row
End With
End Sub``````

#### grahambza

##### New Member
Thanks VOG II - worked like a charm

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,373
Messages
5,836,875
Members
430,460
Latest member
cristian270

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back