Avatar of John Carney
John Carney
Flag for United States of America asked on

Excel VBA equivalent of a range definition

This range definition (LastCol) gives me the last column of my 11-column wide Table1:

=OFFSET(Table1,0,10,ROWS(Table1),COLUMNS(Table1)-10)

How do I express that in VBA so that I don't have to create and name the range before running a macro that relies on it?

Thanks,
John
Microsoft Excel

Avatar of undefined
Last Comment
nutsch

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Patrick Matthews

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
SOLUTION
nutsch

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
John Carney

ASKER
I wasn't expecting the answer to be so simple and common sense logical. Thanks, Patrick.

And thanks Thomas for a way to approach it when there's no pre-defined range to play off of.

- John
Patrick Matthews

Glad to help.  BTW, if you always want the last column, but are not sure which column number that would be...

With Range("Table1")
    Set MyLastColumn = .Columns(.Columns.Count)
End With

Open in new window

nutsch

Glad to see you're making progress on the VBA front, John.

Thomas
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes