Worksheet change

Valentin

Board Regular
Joined
Oct 29, 2010
Messages
96
Office Version
  1. 365
Platform
  1. Windows
I have two worksheet change events, how can I code them on one sheet
Code1
VBA Code:
Private Sub worksheet_change(ByVal target As Range)
If Intersect(target, Range("D4:D67")) Is Nothing Then Exit Sub
Application.EnableEvents = False
On Error GoTo ErrorRoutine
target = target + CellCopy
ErrorRoutine:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(target, Range("D4:D67")) Is Nothing Then Exit Sub
CellCopy = target
End Sub

Code2
VBA Code:
Sub worksheet_change(ByVal target As Range)
Set target = Range("E4")
If target.Value = True Then
Call EMJokerPlusUnHide
End If
If target.Value = False Then
Call EMJokerPlusHide
End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Incorporate them into the Workbook_sheetchange event, instead.

Then do a test for sheet.name, before running each bit of code:
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    If Sh.Name = "Sheet1" And Target.Address = "$A$1" Then
    
        blah blah
    
    End If

End Sub
 
Upvote 0
How is E4 being changed?
 
Upvote 0
Ok, how about
VBA Code:
Private Sub worksheet_change(ByVal Target As Range)
   If Not Intersect(Target, Range("D4:D67")) Is Nothing Then
      Application.EnableEvents = False
      On Error GoTo ErrorRoutine
      Target = Target + CellCopy
   ElseIf Target.Address(0, 0) = "E4" Then
      If Target.Value Then
         Call EMJokerPlusUnHide
      Else
         Call EMJokerPlusHide
      End If
   End If
ErrorRoutine:
   Application.EnableEvents = True
End Sub
 
Upvote 0
Solution
Sorry, Problem solved , I typed incorrectly
Thanks for the solution;
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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