Worksheet_change only when user input value

zico8

Board Regular
Joined
Jul 13, 2015
Messages
225
Hi,

Is there any way to use worksheet_change event only when user input some value?
I do not want to execute event when value will be added by macro.

I know that can use Application.EnebleEvents but I really do not like it couse of possibility of demage all macros when some error occurring during events are disabled.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Just code the "EnableEvents" false/true around the [few?] lines of code that do it within a macro?
 
Upvote 0
Using EnableEvents=False will not increase any risk of damage due to errors.
If your code errors, EnableEvents=False will not interfere with VBA raising an error and stopping macro execution.
 
Upvote 0
Hi,

Is there any way to use worksheet_change event only when user input some value?
I do not want to execute event when value will be added by macro.

I know that can use Application.EnebleEvents but I really do not like it couse of possibility of demage all macros when some error occurring during events are disabled.

If you use propper error handling, you could ensure events are always set to TRUE should an error occur ...

Something like this maybe :
Code:
Sub MacroTest()

    On Error GoTo errHandler
    
    Application.EnableEvents = False
    
   [B][COLOR=#008000] 'If an error occurs, code will jump to errHandler and set the Events back to True.[/COLOR][/B]
    
   [COLOR=#008000][B] 'Edit the worksheet cell[/B][/COLOR]
    Sheet1.Range("a1") = "Hello"
    
    
errHandler:
    Application.EnableEvents = True


End Sub
 
Last edited:
Upvote 0
Hi,

Is there any way to use worksheet_change event only when user input some value?
I do not want to execute event when value will be added by macro.

I know that can use Application.EnebleEvents but I really do not like it couse of possibility of demage all macros when some error occurring during events are disabled.

Or better still inform the user if an error occurs... like this :

Code:
Sub MacroTest()

    On Error GoTo errHandler
    
    Application.EnableEvents = False
    
    [B][COLOR=#008000]'If an error occurs, code will jump to errHandler and set the Events back to True.[/COLOR][/B]
    
    [COLOR=#008000][B]'Edit the worksheet cell[/B][/COLOR]
    Sheet1.Range("a1") = "Hello"
            
errHandler:

    Application.EnableEvents = True

    If Err Then
        Err.Raise Err
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top