VBA End(xlUp) ignore blank

EOAEvan

Active Member
Joined
Sep 20, 2007
Messages
399
Im using the line .End(xlUp) to test for the last used cell. However I have forumlas the have the result of "". I want to test for the last used row that is greater than 0 and ignore the cells that have the formula with the result of "".

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
EOAEvan,

Assuming column A, you can use this. If you have more than 65000 rows, just adjust the range.
Code:
    Dim LastUsedRow As Long
    LastUsedRow = [LOOKUP(2,1/(A1:A65000<>""),ROW(A1:A65000))]
 
Upvote 0
Maybe like this:
Code:
Dim lLR As Long
lLR = Sheets(1).Cells.Find("*", Cells(Rows.Count, Columns.Count), xlValues, xlPart, xlByRows, xlPrevious).Row
 
Upvote 0
Maybe like this:
Code:
Dim lLR As Long
lLR = Sheets(1).Cells.Find("*", Cells(Rows.Count, Columns.Count), xlValues, xlPart, xlByRows, xlPrevious).Row

I should have been more clear in my original post. I need to find the last cell in a specific row rather than the whole sheet.
 
Upvote 0
Hi

Another option, based on Shrivallabha's solution, for a specific range, for ex. Column A:

Code:
Dim lLR As Long
lLR = Sheets(1).Columns("A").Find("*", LookIn:=xlValues, SearchDirection:=xlPrevious).Row
 
Upvote 0

Forum statistics

Threads
1,215,440
Messages
6,124,882
Members
449,193
Latest member
PurplePlop

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