Ask Experts Questions for FREE Help !
Ask
    WesB's Avatar
    WesB Posts: 2, Reputation: 1
    New Member
     
    #1

    Jan 26, 2010, 11:11 AM
    How do you reference the last row # as a variable when the number of rows changes?
    I download constantly changing financial worksheets, each with a different number of rows of information. I need to reference the last row in a specific column as a variable to use as a variable cell reference in Excel VBA, so that I can format the entire column from the last row, formatting upward. (i.e. using the value of the row number in ActiveCell.SpecialCells(xlLastCell).row, and using that with the specific column name. e.g. "P"rownumbervariable.)
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Jan 26, 2010, 03:13 PM

    This is how I do it:

    Store the last row as a variable:
    Code:
    Dim LR as Long
    LR = Range("P" & Rows.Count).End(xlUp).Row
    Store the VALUE of the last cell with data in a column:
    Code:
    Dim MyVal as String
    MyVal = Range("P" & Rows.Count).End(xlUp).Value
    Does that get you started?
    WesB's Avatar
    WesB Posts: 2, Reputation: 1
    New Member
     
    #3

    Jan 26, 2010, 04:36 PM

    JB,
    The first option looks like the answer I needed.
    Many Thanks!
    Wes

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

How to Knit Short Rows? [ 1 Answers ]

How do you knit short rows? I am confused on how to wrap around stitches.

Combine rows of text into one cell [ 12 Answers ]

Hi everyone I hope you are all well! I have an excel problem and it would be much appreciated if someone has the time to take a look... In column A I have product names, in B I have product categories and in C:H the product categories from column B are titles and the name of the subcategory...

Variable Overhead efficiency variable [ 1 Answers ]

Variable overhead is applied in the basis of standard direct labor-hours. If the direct labor efficiency variance is unfavorable, the variable overhead efficiency variance will be? a Favorable b unfavorable c zero d indeterminable


View more questions Search