VBA Worksheet_Change

GRowe

New Member
Joined
Feb 1, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi All,
Im new to excel...
I have a question, I currently putting together an inventory spread sheet but having trouble using 2x Worksheet_Change actions and from reading about on other related issues it seems you cant run 2 in the same place.
This is what I'm trying to achieve,
Changing the name of the worksheet based on a cell reference and then change the colour of the tab, based on a result once the order has been fully received. below is a example of what I've got already, Independently they both work,

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("j7")) Is Nothing Then
If Range("j7") = Empty Then
ActiveSheet.Name = "Client Unspecified-" & ActiveSheet.Index
Else
ActiveSheet.Name = Range("j7")
End If
End If
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice
If Target.Address = "$Q$15" Then
Select Case Target.Value
Case "No"
Me.Tab.Color = vbRed
Case "Yes"
Me.Tab.Color = vbGreen
Case Else
Me.Tab.Color = vbBlue
End Select
End If
End Sub


Can anyone help??
Thank you in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Just put your 2 codes in one Worksheet__Change.
 
Upvote 0
I'm probably doing something else wrong,
I'm getting an error Saying Compile Error ,Only comment after end sub, End function, or end properly.
with Target, highlighted in the string "If Not Intersect(Target,"
could you give me an example on how the code should look..
Thanks
 
Upvote 0
i think i my have sorted it i had the colour tab code first so i swapped it round...
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,874
Members
449,056
Latest member
ruhulaminappu

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