If a cell is green, fill adjacent cells background color on th right side automatically

sensiwood

New Member
Joined
Nov 28, 2016
Messages
3
Hi,

I am just seeking the method to achieve following scenario.
When setting a cell as green, the adjacent 5 cells' background color on the right side will be filled grey automatically.
This rule would be expected to apply to the whole worksheet.

Is it possible to do this in conditional formatting?
Thanks a lot in advance!
Ronnie
 
Code:
Sub GreenToH5Grey()
  Dim c As Range, r As Range
  For Each c In ActiveSheet.UsedRange
    '5287936=a green, 12566463 (a grey)
    If c.Interior.Color = 5287936 Then _
      c.Offset(, 1).Resize(, 5).Interior.Color = RGB(191, 191, 191)
  Next c
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
not to say your guys' codes are great, but I still think this is a matter for Conditional Formatting. If the OP can tell us why he changes the color to green we can work out the CF formulas.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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