Return the value of the last used row in a column

Joined
Nov 19, 2008
Messages
29
As the title would suggest I want to return the value of the last used row of data in column 'A', I know that I can use something like

LastRow = ActiveSheet.UsedRange.Rows.Count

But the tricky part is that I want the code to ignore any cell which contains a formula.

Anyone know how to do this?

Thanks!!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I guess maybe I could use a while loop to loop backwards until it found the first cell in the column without a formula derived value (i.e. a user inputted value)

But not exactly sure how I would go about phrasing it!
 
Upvote 0
Maybee...

Code:
Sub tst()
Dim LastRow As Integer
On Error Resume Next
With ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
    LastRow = .Areas.Count
    LastRow = .Areas(LastRow).Cells(1, 1).Row + .Areas(LastRow).Rows.Count - 1
End With
On Error GoTo 0
End Sub

HTH
 
Upvote 0
Hmm that code doesnt appear to work. Returns a value of 0 which would indicate that it is finding a calculated cell! Is there a way I can return the reference of the cell it is finding rather than the value so that I can check exactly where it is stopping?
 
Upvote 0
The .End property might reference a cell that contains a formula.
This will return the value last cell in column A that holds a constant

Code:
With Range("A:A").SpecialCells(xlCellTypeConstants)
    With .Areas(.Areas.Count)
        With .Item(.Cells.Count)
            MsgBox .Address & " contains " & .Value
        End With
    End With
End With
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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