I’ve got a worksheet and cell A1 to A100 consist of a drop down list which was created using data validation. When the user selects a value from the list, for that particular row, certain cells need to be filled with yellow. This is needed, because the worksheet consists a lot of fields to be filled in. to make it easy for the user to fill in the values, we need to highlight only the required cells based on the value the user selects from the drop down list.
Row 1 consists of fields
if "A" is selected from drop down list in cell A2, cell B2 and C2 needs to be filled with yellow
if "B" is selected from drop down list in cell A3, cell B3 & C3 & D3 needs to be filled with yellow
if nothing is selected, all the cells shouldnt be filled with color.
thanks,
Hello,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range, MyColor
If Intersect(Range("A1:A100"), Target) Is Nothing Then Exit Sub
With Target
.Range("B1:D1").Interior.Color = xlNone
Select Case .Value
Case Is = "A"
Set MyRange = .Range("B1:C1")
MyColor = 65535
Case Is = "B"
Set MyRange = .Range("B1:D1")
MyColor = 65535
Case Else
Set MyRange = .Range("B1:D1")
MyColor = xlNone
End Select
MyRange.Interior.Color = MyColor
End With
End Sub
Ivan
|