ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Visual Basic suddenly stopped working (https://www.excelbanter.com/excel-programming/379011-visual-basic-suddenly-stopped-working.html)

amirstal

Visual Basic suddenly stopped working
 
I have this visual basic code in my spreadsheet.

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

It worked fine, but suddenly it stopped.
How can I make it work again?


NickHK

Visual Basic suddenly stopped working
 
assuming the code was working fine before, I would guess your code stopped
half through and left .EnableEvents=False.
In the immediate window run
Application.EnableEvents = True
and see if the event fires.

NickHK

"amirstal" wrote in message
oups.com...
I have this visual basic code in my spreadsheet.

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

It worked fine, but suddenly it stopped.
How can I make it work again?





All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com