It can be done by modifying the code--not duplicating the procedure.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'one cell at a time only!
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo ErrHandler:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("a2:f3")) Is Nothing Then
Me.Range("h5").Value = Application.Sum(Me.Range("a2:f3"))
ElseIf Not Intersect(Target, Me.Range("x3:y6")) Is Nothing Then
Me.Range("q5").Value = Application.Sum(Me.Range("x3:y6"))
End If
ErrHandler:
Application.EnableEvents = True
End Sub
> It worked fine. Thanks a lot.
> May sheet containes more than one cell that has different formulas and needs
[quoted text clipped - 59 lines]
> >
> > Dave Peterson
Hi,
It is clear for the sum formula's. in a case like this formula where no
range is there:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
that is in cell B5, what should be instead of the range part in:
> ElseIf Not Intersect(Target, Me.Range("x3:y6")) Is Nothing Then
and the second line (assuming the need of 2 line for each as i concluded )
> Me.Range("q5").Value = Application.Sum(Me.Range("x3:y6"))
will be:
Me.Range("B5").Value= "=Mid(CELL(""filename"", A1), Find(""]"",
CELL(""filename"", A1)) + 1, 255)"
I'am not sure if this is right!!!
I also understand that another elseIF statment should be added for each
value needed.
The "Range" part confuses me in the case were no Sum or Average is there!
Khalil
> It can be done by modifying the code--not duplicating the procedure.
>
[quoted text clipped - 84 lines]
>> >
>> > Dave Peterson
Dave Peterson - 25 Jul 2007 12:32 GMT
This formula doesn't depend on what's in A1. It uses A1 as a reference for what
sheet name to return.
And since this formula returns the name of the worksheet, you could use:
me.range("A1").value = me.name
Maybe you can use the worksheet_calculate event to do this -- but I wouldn't.
I'd use that formula.
In fact, I wouldn't replace the other formulas with code either -- but I've said
that already.
> Hi,
> It is clear for the sum formula's. in a case like this formula where no
[quoted text clipped - 107 lines]
> >
> > Dave Peterson

Signature
Dave Peterson