Multiple worksheet changes

Sharonca

New Member
Joined
Jan 9, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
I need to run 3 separate worksheet changes in one worksheet. I am not sure what to do after the the first one.
My code is as follows for the 1st one. I would like to conditionally format when a value changes in Columns AC & CS

This is the first worksheet change

Private Sub Worksheet_Change(ByVal Target As Range)
Dim xOutApp As Object, xMailItem As Object, xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
If Intersect(Target, Range("AG:AG, CW:CW, DB:DB")) Is Nothing Then Exit Sub
ActiveWorkbook.Save
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Cell(s) " & Target.Address(False, False) & " (In the CPM Tracker press F5 to go to the cell referenced to see what TI Field needs to be updated) in the worksheet '" & Me.Name & "' were modified on " & _
Format$(Now, "mm/dd/yyyy") & " at " & Format$(Now, "hh:mm:ss") & " by " & Environ$("username") & "."
If Target = "A" Then
With xMailItem
.to = "sharonca@amdocs.com"
.Subject = "Worksheet modified - " & "Ticket " & Range("A" & Target.Row).Value & " - Update TI Date"
.Body = xMailBody
.Display
End With
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Since you can only have one Worksheet_Change event per sheet, and if your data and requirements allow, you may want to write code that once triggered uses the Intersect method. Your current code uses Intersect now to Exit Sub if the Target does not Intersect a certain Range. You could change that so certain sections of code are run or called depending upon where on the sheet the Intersect takes place.
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,945
Members
449,198
Latest member
MhammadishaqKhan

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