Hello,
I want to fill multiple Cells at once that are 5 columns off from each other, so I use
But the amount of cells is variable. Everytime we need a new set of columns, I need to change the code to implement them.
What I would like is to "fill" or enhance the union with all needed Cells with a For..Next loop, so that I never need to hardcode the cells anymore. Like saving the union range into a variable.
This approach shows the direction I want this to go
I have tried different methods with filling cells one by one, but unfortunately this is a performance killer as it took my code several seconds. With filling all cells at once using union it takes less than 1 second which is what I need.
Thanks in advance
I want to fill multiple Cells at once that are 5 columns off from each other, so I use
Code:
Union(Cells(2, i), Cells(2, i + 5), Cells(2, i + 10), ...) = "Text"
But the amount of cells is variable. Everytime we need a new set of columns, I need to change the code to implement them.
What I would like is to "fill" or enhance the union with all needed Cells with a For..Next loop, so that I never need to hardcode the cells anymore. Like saving the union range into a variable.
This approach shows the direction I want this to go
Code:
For i = 1 to lastcolumn Step 5[INDENT]UnionVariable = UnionVariable + Union(Cells(2, i))[/INDENT]
Next
'Now I have automatically gotten all cells and fill them at once
UnionVariable = "Text"
I have tried different methods with filling cells one by one, but unfortunately this is a performance killer as it took my code several seconds. With filling all cells at once using union it takes less than 1 second which is what I need.
Thanks in advance