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!
Have you tried this:
Dim sVal as String
sVal = "50"
ActiveCell.FormulaR1C1 = "=MAX(RC[-3]:R[" & sVal & " ]C[-3])"
Something like this:
Dim somevar as Integer
somevar = 50
ActiveCell.FormulaR1C1 = "=MAX(RC[-3]:R[" + somevar + "]C[-3])"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.