In my table (Range("A3:K9999")) there's one column E (E3:E9999), which contains drop down lists.
My goal is to have the bg color changed in the whole table line where the user selects an item of the drop-down list in column E. In a second Worksheet named "Input" is a table (A4:A7) which contains the selectable items of that list boxes.
This is my code so far:
Sub Auto_Open() 'ConditionalFormatting
Dim rg As Range
Set rg = Worksheets(1).Range("A3:K9999")
'clear any existing conditional formatting
rg.FormatConditions.Delete
'define the formatting conditions
Dim cond1, cond2, cond3, cond4 As FormatCondition
Set cond1 = rg.FormatConditions.Add(xlExpression, Formula1:="=$E3=Input!A4")
Set cond2 = rg.FormatConditions.Add(xlExpression, Formula1:="=$E3=Input!A5")
Set cond3 = rg.FormatConditions.Add(xlExpression, Formula1:="=$E3=Input!A6")
Set cond4 = rg.FormatConditions.Add(xlExpression, Formula1:="=$E3=Input!A7")
'define the formatting applied for each condition
With cond1
.Interior.Color = vbYellow
End With
With cond2
.Interior.Color = vbRed
End With
With cond3
.Interior.Color = vbGreen
End With
With cond4
.Interior.Color = vbBlue
End With
End Sub
With this I'm just getting some crazy colors in the table when I open the excel file... mainly yellow. Even though there are no selections made in the list boxes. How can I make this code work properly in every drop down list of the whole column E (E3:E9999), is that Sub "Auto_Open()" the right location? And is there a reference error in the conditions formula?