find the last row on a column with formula

mabalo76

New Member
Joined
Apr 10, 2018
Messages
27


The row 2 to row 30 of first column of sheet1 contain formula below

=IF(ISBLANK(sheet2!D2),"",sheet2!D2)
=IF(ISBLANK(sheet2!D3),"",sheet2!D3)
.
.
=IF(ISBLANK(sheet2!D30),"",sheet2!D30)


The thing is only row two actually have a value, from row 3 to row 30 is blank based on formula, but when i use below function
lRow = Cells(Rows.Count, 1).End(xlUp).Row

the lRow i got is 30

I want to get 2 in this case.

Anybody can help please?
 

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.
You try:
Code:
Debug.Print Range("A2:A30").SpecialCells(xlCellTypeConstants).Row
 
Last edited:
Upvote 0
You try:
Code:
Debug.Print Range("A2:A30").SpecialCells(xlCellTypeConstants).Row

hmm... i don't think this returns the last row with data (not blank) in column A

Maybe...
Code:
lRow = ActiveSheet.Columns(1).Find(what:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row

M.
 
Last edited:
Upvote 0
I just find out Debug.Print Range("A2:A30").SpecialCells(xlCellTypeConstants).Row didn't work

yours works fine.

Thanks,
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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