VBA- Cell colour change based on cell value change one column only

nlbenz

New Member
Joined
Jul 27, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello
I want to use a macro similar to this one to change the colour of a cell when someone has made a change to a cell within one column only:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 5
End Sub

I am pretty new to the world of VBA and my hunch is that is requires a loop but I'm not sure how to write one. Any assistance would be appreciated!
 

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
No need for a loop, just check that the Target cell (the cell that was acted upon) is in that specific column. Let's say that column is C, then:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("C:C")) Is Nothing Then Target.Interior.ColorIndex = 5
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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