VBA Code

Sakuji

New Member
Joined
May 2, 2004
Messages
32
I was kindly given some code to help me with a spreadsheet and now I would like to add to it. When I input data like "LTS" I would like the cell to colour as indicated in the code but I need the font to be white. What do I need to add to the following code to achieve this?

If Target.value="LTS" then
Target.interior.colorindex=3
end if

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
And you might want to have an Else in there to set it back if it is not LTS, something like:

Code:
If Target.Value = "LTS" Then
    Application.EnableEvents = False
    Target.Interior.ColorIndex = 3
    Target.Font.Color = vbWhite
    Application.EnableEvents = True
Else
    Application.EnableEvents = False
    Target.Interior.ColorIndex = xlNone
    Target.Font.Color = vbBlack
    Application.EnableEvents = True
End If
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

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