PDA

View Full Version : Solved: Refer to the Last Row



YasserKhalil
10-27-2010, 11:07 PM
Hi everybody
I learnt to refer to the last row by code
Now I have column B with formulas until B100 but the results are until B11 and the other cells in the column are bank
I want to refer to the Last Row to be 11 not 100
Here's my code but it appears to be 100 not 11
Dim LastRow As Integer
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
MsgBox LastRow

ilyaskazi
10-27-2010, 11:38 PM
Assuming your unwanted rows returns 0 (zero) you can try this..

Dim rFound As Range
On Error Resume Next
Set rFound = Columns(2).Find(What:="0", After:=Cells(1, 2), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
On Error GoTo 0
If Not rFound Is Nothing Then Application.Goto rFound, True

MsgBox rFound.Row

YasserKhalil
10-28-2010, 12:36 AM
Thanks a lot for your help
I appreciate your help Mr. ilyaskazi