Hi,
I have a formula in a cell C1 with a range name called MyAVG. (The formula is simply =AVERAGE(A:A))
Each time I run a macro, it inserts two columns to the left of MyAVG and places values in the columns.
Now I want the macro to edit the formula in MyAVG to include the first of those two columns. IOW: The formula is edited to become =AVERAGE(A:A,C:C).
When I run the macro again, it inserts two new columns left of MyAVG, adds values to it and must edit the formula to: =AVERAGE(A:A,C:C,E:E)
Any ideas if this can be done?
TX
Add to Function References
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Add to Function References
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 78643
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Add to Function References
Like this:
Code: Select all
Dim strFormula As String
strFormula = Range("MyAVG").FormulaR1C1
strFormula = Left(strFormula, Len(strFormula) - 1) & ",C[-2])"
Range("MyAVG").FormulaR1C1 = strFormula
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Add to Function References
TX...as always.
I tried something similar but just could not resolve the syntax.
I tried something similar but just could not resolve the syntax.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.