Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49948

Column References in VBA

$
0
0
Probalby a very basic question, but I am still new to VBA. How do I reference a column by its letter, rather than its number?

At the moment I have various column numerical references in my code, e.g.

Code:

For i = 40 To 51
but if for whatever reason columns get deleted, I have to go through all the code and change the numberical references, which is a pain. What I would like is to have a way of referencing the column in the code, so that if a column is deleted or inserted, the column references are automatically updated across the code in a similar way to standard formula. Is this possible to do?

Something along the lines of:

Code:

For i = column AN To column AY
but in a way that if one column say to the left of AN were deleted, all code references would automatically resulting, in this case to:

Code:

For i = coulmn AM To column AX
Many thanks

Viewing all articles
Browse latest Browse all 49948

Trending Articles