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

Microsoft Excel

Avatar of undefined
Last Comment
av8orct

8/22/2022 - Mon
Martin Liss

Last column can be found with

lngLastColumn = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
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?
Martin Liss

You can experiment with


Dim R As Range
Set R = ActiveSheet.UsedRange
MsgBox (Cells(R.Rows.Count, R.Column).Value)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
byundt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
av8orct

ASKER
that did it, thank you byundt!