Lookup last valid row

grahambza

New Member
Joined
Sep 7, 2005
Messages
19
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 does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I used countif(A1:A200,"*") to get the answer

How do i use this result in a sort macro

Currently my macro contains
ActiveWorkbook.Names.Add Name:="Suppliers", RefersToR1C1:= _
"=Sheet3!R1C1:R200C1"

Any help is appreciated
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
ActiveWorkbook.Names.Add Name:="Suppliers", RefersToR1C1:= _
"=Sheet3!R1C1:LRC1"
'"=Sheet3!R1C1:R200C1"

And of course I got an error in the range selection

Any help is appreciated
 
Upvote 0
Please ignore my last post
I worked out how to use the offset suggested by VOG II - and now have another problem which i will post separately
 
Upvote 0
Try this

Code:
Sub test()
Dim LR As Long
With Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    ThisWorkbook.Names.Add Name:="Suppliers", RefersTo:=.Range("A1:A" & LR)
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,090
Latest member
vivek chauhan

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top