I want to select an entire column in Excel using VBA code, normally I'd do that like this Range("D:D").select
However in the current situation I only have the column numbers and I'd like to avoid having to convert the numbers into the corresponding letter. I have found a way to that here.
Can this be done?
You have a few options:
.EntireColumn
:Code
Dim ColNumner As Long
ColNumner = 5
Cells(1, ColNumner).EntireColumn.Select
Columns(ColNumner)
:Code
Dim ColNumner As Long
ColNumner = 5
Columns(ColNumner).Select
Note: you should stay with from using Select
. For instance, if you want to copy this column, you could use Columns(ColNumner).Copy
, etc...