I have a VBA code which one of the line looks like this
analysisSheet.Cells(i, tempCell).FormulaR1C1 =
“=AVERAGE(‘Data1’!R[-2]C[-7])”
I want to be able to change ‘Data1’ sheet so that user can dynamically choose the sheet he/she wants to analyze. For example, if user chooses ‘Data2″ Then the code will run like this.
analysisSheet.Cells(i, tempCell).FormulaR1C1 =
“=AVERAGE(‘Data2’!R[-2]C[-7])”
I tried creating string variable and putting that in, but it didn’t work.
Does anyone have any idea?
Thank you in advance.
You should be able to use a string variable, e.g., SheetName, as you described: