Reputation: 527
VBA will let me do this:
Columns("A:A").Select
But I need to do this:
Columns("ColNumToLet:ColNumToLet").Select
where ColNumToLet is a variable of type variant and has a value of A. VBA throws a Type mismatch error. What is the correct syntax?
Upvotes: 0
Views: 74
Reputation: 96791
Here is how to use letters to define a span of columns:
Sub marine()
alpha = "A"
omega = "O"
Columns(alpha & ":" & omega).Select
End Sub
Upvotes: 2
Reputation: 166835
No need to convert to letters:
Columns(ColNum).Select
If you need to use letters then
Columns(ColNumToLet).Select
will also work.
Upvotes: 2