PC Review


Reply
Thread Tools Rate Thread

Code Works on Windows 2000 but not on XP

 
 
amirstal
Guest
Posts: n/a
 
      20th Jul 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      20th Jul 2007
I'm on 2003 (XP?) and it seems to work here. What's the problem?

"amirstal" wrote:

> 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
>
>

 
Reply With Quote
 
amirstal
Guest
Posts: n/a
 
      20th Jul 2007
On Jul 20, 2:28 pm, Barb Reinhardt
<BarbReinha...@discussions.microsoft.com> wrote:
> I'm on 2003 (XP?) and it seems to work here. What's the problem?
>
> "amirstal" wrote:
> > 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


The problem is that when I enter the first amount, it does not show
the second amount automatically, like it does on Windows 2000. I have
XP version 2002, SP2.

Amir

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      20th Jul 2007
One problem I see is that it's that prone to crashing because of lack of
error checking there's a very good chance of leaving EnableEvents as false
meaning the macro won't work at all after the first crash.

Mike

"amirstal" wrote:

> On Jul 20, 2:28 pm, Barb Reinhardt
> <BarbReinha...@discussions.microsoft.com> wrote:
> > I'm on 2003 (XP?) and it seems to work here. What's the problem?
> >
> > "amirstal" wrote:
> > > 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

>
> The problem is that when I enter the first amount, it does not show
> the second amount automatically, like it does on Windows 2000. I have
> XP version 2002, SP2.
>
> Amir
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      20th Jul 2007
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
>


 
Reply With Quote
 
amirstal
Guest
Posts: n/a
 
      20th Jul 2007
On Jul 20, 2:48 pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> One problem I see is that it's that prone to crashing because of lack of
> error checking there's a very good chance of leaving EnableEvents as false
> meaning the macro won't work at all after the first crash.
>
> Mike
>
> "amirstal" wrote:
> > On Jul 20, 2:28 pm, Barb Reinhardt
> > <BarbReinha...@discussions.microsoft.com> wrote:
> > > I'm on 2003 (XP?) and it seems to work here. What's the problem?

>
> > > "amirstal" wrote:
> > > > 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

>
> > The problem is that when I enter the first amount, it does not show
> > the second amount automatically, like it does on Windows 2000. I have
> > XP version 2002, SP2.

>
> > Amir


Yes, that what happened. It crashed and now it won't work. How can I
fix that problem?

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      20th Jul 2007
We TOP post here.

sub fixit()
Application.EnableEvents = True
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"amirstal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Jul 20, 2:48 pm, Mike H <Mi...@discussions.microsoft.com> wrote:
>> One problem I see is that it's that prone to crashing because of lack of
>> error checking there's a very good chance of leaving EnableEvents as
>> false
>> meaning the macro won't work at all after the first crash.
>>
>> Mike
>>
>> "amirstal" wrote:
>> > On Jul 20, 2:28 pm, Barb Reinhardt
>> > <BarbReinha...@discussions.microsoft.com> wrote:
>> > > I'm on 2003 (XP?) and it seems to work here. What's the problem?

>>
>> > > "amirstal" wrote:
>> > > > 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

>>
>> > The problem is that when I enter the first amount, it does not show
>> > the second amount automatically, like it does on Windows 2000. I have
>> > XP version 2002, SP2.

>>
>> > Amir

>
> Yes, that what happened. It crashed and now it won't work. How can I
> fix that problem?
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in 2000 but error in 2003 Steve S Microsoft Access Form Coding 3 19th Mar 2009 02:02 AM
code works in 2000, won't work in 2007 Angie Microsoft Access VBA Modules 1 29th Oct 2008 07:23 PM
VB Code works in 2000, but not 2003 mleviton@juno.com Microsoft Excel Programming 2 21st Jun 2006 09:13 AM
Detail_Format code works in 2000 but not 2003? Joe Sutphin Microsoft Access Reports 1 3rd Oct 2005 10:23 PM
VBA Code works in 2000 not 97 Michael Beckinsale Microsoft Excel Programming 1 20th Jan 2004 05:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:29 AM.