It's always helpful to define what you mean when you say "doesn't work" to
tell us what doesn't work.
I tested yours on VistaHomePremium with xl2003 with all updates and it
worked fine.
But this may be better.Notice the trap for 0 in .offset(,-4)
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("I2,G10:I100")) Is Nothing Then
Select Case Target.Column
Case Is = 7
Target.Offset(, 2) = Target.Offset(, -2) * Target * -1
Case Is = 9
If Target.Offset(, -4) = 0 Then Exit Sub
Target.Offset(, -2) = Target / Target.Offset(, -4) * -1
Case Else
End Select
End If
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"amirstal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI,
>
> Does anyone have an idea why this code works on Windows 2000 SP4 but
> not on XP???
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Application.EnableEvents = False
> If Target.Address = "$G$10" Then _
> Target.Offset(, 2) = Target.Offset(, -2) * Target * (-1)
> If Target.Address = "$I$2" Then _
> Target.Offset(, -2) = Target / Target.Offset(, -4) * (-1)
> Application.EnableEvents = True
>
> If Target.Row < 10 Then Exit Sub
> Application.EnableEvents = False
> If Target.Column = 7 Then _
> Target.Offset(, 2) = Target.Offset(, -2) * Target * (-1)
> If Target.Column = 9 Then _
> Target.Offset(, -2) = Target / Target.Offset(, -4) * (-1)
> Application.EnableEvents = True
>
>
> End Sub
>
>
> Thanks,
>
> Amir
>