Ignore Cells with Formulas to get Last Row?

specialtg

New Member
Joined
Aug 21, 2009
Messages
4
Hi there, I am trying to find the last row populated with values in my wks. Not the last row of formulas!

This is happening b/c my wks has empty cells with formulas and Excel is seeing those as valid rows??

Below is the variable LastRow I am trying to populate. I would think the part of code "lookIn:=xlValues" would bypass the formulas but its not working.

Any help would be great! Thanks so much!

LastRow= Cells.Find(What:="*", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
The formulas are displaying no data...if there is data in another worksheet the rows will populate....Thanks
 
Upvote 0
Code:
Private Sub tst()
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    For x = lr To 1 Step -1
        tvar = Cells(x, 1).Formula & Cells(x, 1)
        If Cells(x, 1) <> "" Then
            lr = x
            Exit For
        End If
    Next x
    'LR is your last line of data actual data
End Sub

<b>Sheet10</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:10pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:64px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td >DATA</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >12</td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >13</td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >A13</td><td >=IF(A1="","",A1)</td></tr></table></td></tr></table>
 
Upvote 0
Thank you so much...but it didnt work. It still brought me down to row 702 where as the data is only populated to row 47

I did try to add .Value to the If stmt thinking that may work...to no avail. What is the purpose of tvar?
Thanks so much for you help and attention!!! :)


Code:
lr = Cells(Rows.Count, "A").End(xlUp).Row
    For x = lr To 1 Step -1
        tvar = Cells(x, 1).Formula & Cells(x, 1)
        If Cells(x, 1).Values <> "" Then
            lr = x
            Exit For
        End If
Next x
 
Upvote 0
It does work! Minor tweak...THANKS SO MUCH!!

Code:
lr = Cells(Rows.Count, "A").End(xlUp).Row
    For x = lr To 1 Step -20
        tvar = Cells(x, 1).Formula & Cells(x, 1)
        If Cells(x, 1).Value <> " " Then
            lr = x
            Exit For
        End If
Next x
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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