Reputation: 1
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
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