Hello!
I'm writing a longer code, but can't find a solution to a problem. I have a variable that is a number of columns that need to be added (from 2 to 4).
The problem is that the columns to add are every 5 columns (left), that is:
Is there any way to get as many columns in a formula added as variable value? The workaround would be using "Select case" for 2-4, but some time in the future there may be more values needed, so I'm reluctant to use it that way.
I'm writing a longer code, but can't find a solution to a problem. I have a variable that is a number of columns that need to be added (from 2 to 4).
The problem is that the columns to add are every 5 columns (left), that is:
VBA Code:
'example for adding 2 columns, variable=2
ActiveCell.FormulaR1C1 = "=RC[-5]+RC[-10]"
VBA Code:
'example for adding 4 columns, variable=4
ActiveCell.FormulaR1C1 = "=RC[-5]+RC[-10]+RC[-15]+RC[-20]"