Coloring cells in sheet 2 based on data sheet 1 Excel VBA
Solved/Closed
Related:
- Coloring cells in sheet 2 based on data sheet 1 Excel VBA
- Tentacle locker 2 - Download - Adult games
- Fnaf 1 download pc - Download - Horror
- Tentacle locker 1 - Download - Adult games
- Mark sheet in excel - Guide
- Sheet right to left in google sheet - Guide
2 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Oct 24, 2022 at 12:05 PM
Oct 24, 2022 at 12:05 PM
Hi Sue-Ellen,
For your code to work, some changes need to be made:
Sub ChangeColor() Set Myrange = Sheets("Sheet1").Range("C46") For Each cell In Myrange Select Case cell.Value Case Is = "Yes" Sheets("Sheet2").Rows("416:416").Interior.ColorIndex = 16 Case Is = "No" Sheets("Sheet2").Rows("416:416").Interior.ColorIndex = xlNone End Select Next cell End Sub
I would do it like this:
Sub RunMe() If Sheets("Sheet1").Range("C46") = "Yes" Then Sheets("Sheet2").Rows(416).Interior.ColorIndex = 16 If Sheets("Sheet1").Range("C46") = "No" Then Sheets("Sheet2").Rows(416).Interior.ColorIndex = xlNone End Sub
But this can also be done using Conditional Formatting.
Best regards,
Trowa
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Nov 3, 2022 at 12:37 PM
Nov 3, 2022 at 12:37 PM
Hi Sue-Ellen,
Sure!
Paste the code below under Sheet1 instead of a standard Module:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Range("C46"), Target) Is Nothing Then Exit Sub If Target.Value = "Yes" Then Sheets("Sheet2").Rows(416).Interior.ColorIndex = 16 If Target.Value = "No" Then Sheets("Sheet2").Rows(416).Interior.ColorIndex = xlNone End Sub
Best regards,
Trowa
Oct 28, 2022 at 02:25 AM
Hi Trowa,
Thank you very much! Is it also possible to make it an automatically change? For now I have to run the macro, but I want to let the colour change automatically when I change the into yes or no.
Best regards,
Sue Ellen