So in excel vba I'm trying to select a range, but a different range every time. I have a loop going, but I was wondering how I would actually write the code to change the range. This is what it would look like for a single range.
Range("B7").Select
Is there a way to do this with integers instead of strings such as "B7"
i.e
Range(i).Select
I need it to select a single column. Any advice would be appreciated.
Thanks
Columns(1).Select
– xQbertCells([row],[column])
(likeCells(7, 2)
would be B7) – Dirk Reichel.Select
can cause headaches in your code. What @xQbert will certainly work if you are trying to select a whole column. Say you wanted to change the range but only to loop through cells in one column, you could use something likeRange("B" & i)
– KyleRange("B7").EntireColumn
or with a variable,Dim myCol as Long // myCol = Range("B7").Column
But you don't "really" want to select the column, but do something with that column. Check out the Thread I linked to, it will save you many headaches and help your code run faster. – BruceWayne