Remove fill color when update cell

noelmus

Board Regular
Joined
Dec 30, 2018
Messages
105
I have a cell with drop down list which has a yellow fill color. Is there a way that the yellow fill color will be removed when I update this cell?

Thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Put the following in the events of your sheet

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("E3")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        If Target.Value = "" Then
            Target.Interior.ColorIndex = 6
        Else
            Target.Interior.ColorIndex = xlNone
        End If
    End If
End Sub
 
Upvote 0
Hi
I have already the code below and when I add yours, it gave this;
Compile error:
Ambiguous name detected: Worksheet_Change

Even the first line of your code became highlighted: Private Sub Worksheet_Change(ByVal Target As Range)


Present code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("E20,H20")) Is Nothing Then
If Target.Value = "" Then
Range("C11").ClearContents
Else
Range("C11").Value = Application.UserName
End If
End If
Application.EnableEvents = True
End Sub

Thanks
 
Upvote 0
The unified code would be like this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("E20,H20")) Is Nothing Then
        If Target.Value = "" Then
            Range("C11").ClearContents
        Else
            Range("C11").Value = Application.UserName
        End If
    End If
    Application.EnableEvents = True
'
    If Not Intersect(Target, Range("E3")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        If Target.Value = "" Then
            Target.Interior.ColorIndex = 6
        Else
            Target.Interior.ColorIndex = xlNone
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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