Jmoz092
Board Regular
- Joined
- Sep 8, 2017
- Messages
- 184
- Office Version
- 365
- 2011
- Platform
- Windows
- MacOS
I'm trying to modify the code found in this thread for a workbook I have. I've added the formulas that suit my conditional formatting requirements, but I need help/education with applying the rules to each row on the worksheet (2-31) and also modifying the sheet name(red lettering) reference in two of the rules (the sheet name is dynamic).
Code:
[COLOR=#454545][FONT="][SIZE=2]Private Sub Worksheet_Change(ByVal Target As Range)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]
[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]Dim thecell As Range[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]
[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]For Each thecell In Target[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] If (Not IsEmpty(thecell)) Then[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] With thecell[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] If .Value = " =and($I$5= ""Yes"", $K$5=""n/a"",MIN([COLOR=#ff0000]'Data 201707001'[/COLOR]!E49:E68)=0)" Then[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ' red[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] thecell.Interior.Color = RGB(252, 13, 27)
[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ElseIf .Value = " =OR($I$5=""Yes"", $K$5=""No"")" Then[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ' yellow[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] .Interior.Color = RGB(255, 253, 56)
[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ElseIf .Value = " =[COLOR=#ff0000]'Data 201707001'[/COLOR]!$I$34>45" Then[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ' green[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] .Interior.Color = RGB(205, 254, 204)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Else
[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] ' white[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] .Interior.Color = RGB(255, 255, 255)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] End If[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] End With[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Else[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] 'white[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] thecell.Interior.Color = RGB(255, 255, 255)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] End If[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]Next[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]End Sub[/SIZE][/FONT][/COLOR]