T
Tim
Hi,
In cell F9 I have this formula: =SUMPRODUCT(--(MONTH
(M4:M100)=3),E4:E100). What I'm trying to do is
when type any number in cell C3 and run a macro or press
Enter to change the number "3" in the formula in cell F9
to the number in cell C3.
I tried next three ways with no success:
First way: Recorded this macro:
Range("C3").Select
ActiveCell.FormulaR1C1 = "2"
Range("F9").Select
ActiveCell.FormulaR1C1 = _
"=SUMPRODUCT(--(MONTH(R[-5]C[7]:R[91]C[7])=2),R[-
5]C[-1]:R[91]C[-1])"
End Sub
It doesn't work.
Second way: Changed formula in F9 to IF formula-works
fine with 7 if statements but it looks like Excel limits
the if formula only to 7
if statements because after the 7th if statement I
receive an error message for the formula But I need to
change "3" in the sumproduct formula
in F9 at least 12 times-for every month so this way also
doesn't do the job.
Third way : With the next Worksheet Event:
With ActiveSheet
If .Range("c3").Value = 2 Then
.Range("f9").Formula = "=SUMPRODUCT(--(MONTH
(M4:M100)=2),E4:E100)"
If .Range("c3").Value = 3 Then
.Range("f9").Formula = "=SUMPRODUCT(--(MONTH(M4:M100)
=3),E4:E100)"
....
End If
End With
It also doesn't work.
I give you the above example only with one formula in
cell F9 to keep it maximum clear and simple. In fact I
have many sumproduct formulas in
my worksheet which makes the process of the automated
updating of the months in the formulas very important and
I believe it won't be a problem for the Gurus in this
news group to manage with it.
Tim
In cell F9 I have this formula: =SUMPRODUCT(--(MONTH
(M4:M100)=3),E4:E100). What I'm trying to do is
when type any number in cell C3 and run a macro or press
Enter to change the number "3" in the formula in cell F9
to the number in cell C3.
I tried next three ways with no success:
First way: Recorded this macro:
Range("C3").Select
ActiveCell.FormulaR1C1 = "2"
Range("F9").Select
ActiveCell.FormulaR1C1 = _
"=SUMPRODUCT(--(MONTH(R[-5]C[7]:R[91]C[7])=2),R[-
5]C[-1]:R[91]C[-1])"
End Sub
It doesn't work.
Second way: Changed formula in F9 to IF formula-works
fine with 7 if statements but it looks like Excel limits
the if formula only to 7
if statements because after the 7th if statement I
receive an error message for the formula But I need to
change "3" in the sumproduct formula
in F9 at least 12 times-for every month so this way also
doesn't do the job.
Third way : With the next Worksheet Event:
With ActiveSheet
If .Range("c3").Value = 2 Then
.Range("f9").Formula = "=SUMPRODUCT(--(MONTH
(M4:M100)=2),E4:E100)"
If .Range("c3").Value = 3 Then
.Range("f9").Formula = "=SUMPRODUCT(--(MONTH(M4:M100)
=3),E4:E100)"
....
End If
End With
It also doesn't work.
I give you the above example only with one formula in
cell F9 to keep it maximum clear and simple. In fact I
have many sumproduct formulas in
my worksheet which makes the process of the automated
updating of the months in the formulas very important and
I believe it won't be a problem for the Gurus in this
news group to manage with it.
Tim