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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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