DeanP
07-04-2019, 06:57 AM
I am trying to find the last row with data in a single column. The result should show row 59, however it shows row 1. I have one blank row in my column, which is row 2.
My code:
Sub LastRow1()
Dim sht1 As Worksheet
Dim Lr1 As Long
Dim rng1 As Range
Set sht1 = Worksheets("Contents")
With sht1
Lr1 = Cells(Rows.Count, "C").End(xlUp).Row
MsgBox Lr1
Set rng1 = sht1.Range("C3:C" & Lr1)
End With
End sub
The message box answer = 1.
I can't see what is wrong?
My code:
Sub LastRow1()
Dim sht1 As Worksheet
Dim Lr1 As Long
Dim rng1 As Range
Set sht1 = Worksheets("Contents")
With sht1
Lr1 = Cells(Rows.Count, "C").End(xlUp).Row
MsgBox Lr1
Set rng1 = sht1.Range("C3:C" & Lr1)
End With
End sub
The message box answer = 1.
I can't see what is wrong?