VBA- variable in a range, inside a formula
variables, vba
Solution
Have you tried this:
Dim sVal as String
sVal = "50"
ActiveCell.FormulaR1C1 = "=MAX(RC[-3]:R[" & sVal & " ]C[-3])"
Problem
I have the following code, to calculate the max in a range of cells: ``` Range("E3").Select ActiveCell.FormulaR1C1 = "=MAX(RC[-3]:R[50]C[-3])" ``` How can I replace 50 with a variable in my code? Thanks for your help!