Link to home
Start Free TrialLog in
Avatar of av8orct
av8orct

asked on

Get last column with data from a certain row upwards

I've been trying to get the last column with data in my spreadsheet.

However, what I want to do is to start at a certain row and move upwards. Most of the code I've found looks at the entire spreadsheet.

I am using the below code to find the row to start at:

    'need to find last row of data from manifest (not resources)
    
    last_row = Cells.SpecialCells(xlCellTypeLastCell).row

     For a = last_row To 1 Step -1
     
        Set current_cell = wksht.Cells(a, 2)

        If Len(current_cell.Value) > 0 Then
            
            end_row = a
            Exit For
            
        End If
    
    Next a

Open in new window

Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Last column can be found with

lngLastColumn = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
Avatar of av8orct
av8orct

ASKER

ok, but how do I start at (oh lets say) row 87?

doesnt this start from the 'bottom' of the spreadsheet and work backwards?
You can experiment with


Dim R As Range
Set R = ActiveSheet.UsedRange
MsgBox (Cells(R.Rows.Count, R.Column).Value)
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of av8orct

ASKER

that did it, thank you byundt!