Growth128
Growth128

Reputation: 1

vba code for selecting columns defined names

So i am working on a macro but got stuck trying to figure out how something (i initially believe was simple) turned out to be very difficult.

I am having trouble with the vba code to select columns with defined names.

I believe the generic code to select entire columns is just like the below:

Columns("T:U").Select

but in my case, the columns I want to select are dynamically defined as "wap" and "awap". Specifically wap = T and awap = U to keep things simple.

So, finally, why does neither of the below work?

Columns("wap:awap").Select

Columns(wap:awap).Select

Can someone show me the correct syntax/code to select columns wap and awap? Thank you!!

Upvotes: 0

Views: 276

Answers (1)

BamAlmighty
BamAlmighty

Reputation: 73

If wap and awap are defined as named ranges, then you could use Range("wap:awap").select.

If wap and awap are strings, with a letter indicating a column, you could concatenate the strings into a range - Range(wap & ":" & awap)

Upvotes: 1

Related Questions