ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Change/macros not working (https://www.excelbanter.com/excel-programming/389374-worksheet_change-macros-not-working.html)

Myriam

Worksheet_Change/macros not working
 
Hi all,
I have several sheets using Worksheet_Change. They work great. But... if
there is an error the macros stop working. I close and open the workbook and
the macros as still not working. How do I 'start them up' again?
Thanks for any help.
Regards,

Bob Phillips

Worksheet_Change/macros not working
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
' do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Myriam" wrote in message
...
Hi all,
I have several sheets using Worksheet_Change. They work great. But... if
there is an error the macros stop working. I close and open the workbook
and
the macros as still not working. How do I 'start them up' again?
Thanks for any help.
Regards,




Myriam

Worksheet_Change/macros not working
 
Thanks! Perfect!

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
' do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Myriam" wrote in message
...
Hi all,
I have several sheets using Worksheet_Change. They work great. But... if
there is an error the macros stop working. I close and open the workbook
and
the macros as still not working. How do I 'start them up' again?
Thanks for any help.
Regards,






All times are GMT +1. The time now is 07:23 PM.

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