Link to home
Start Free TrialLog in
Avatar of John Carney
John CarneyFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
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
SOLUTION
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 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
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

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

Thomas