Marco to automatically highlight cell when it changes

RedRooster

New Member
Joined
Mar 23, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
New at this. I have 4 sheets in a workbook that all contain the exact macro code. The macro code it to identify and highlight yellow all cells on each of the sheets when a change takes place. One of the sheets works fine all the time. The other 3 initially work but for some reason start to throw a 104 Application-defined or Object-defined error. How do I get the 3 not working to work along with the one that does work?

Sub Worksheet_Change(ByVal Target As Range)

Range(Target.Address).Interior.Color = RGB(250, 250, 0)

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I believe the issue could be the levels of restriction/protection may not be same for each sheet.
 
Upvote 0
Hi,
Much easier to delete all individual codes in each Sheet module and have in ThisWorkbook module
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
   Target.Interior.Color = RGB(250, 250, 0)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,636
Members
449,043
Latest member
farhansadik

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