bluenose5709
New Member
- Joined
- Dec 15, 2012
- Messages
- 23
- Office Version
- 365
Hi,I am working with Excel 2003 and would liek to automate cell shading.my criteria is text based and ther are 8 permitations so conditional formatting is out of the question.utilising VB i have managed ot gt teh cells to colour as required when i populate with the the relevant info using the code below:" Private Sub Worksheet_Change(ByVal Target As Range)Dim vValue As VariantvValue = Target.ValueOn Error Resume NextIf vValue = "L" ThenTarget.Interior.Color = RGB(0, 255, 0)End IfIf vValue = "CE" ThenTarget.Interior.Color = RGB(205, 204, 153)End IfIf vValue = "XE" ThenTarget.Interior.Color = RGB(153, 153, 255)End IfIf vValue = "HG" ThenTarget.Interior.Color = RGB(255, 102, 0)End IfIf vValue = "SG" ThenTarget.Interior.Color = RGB(0, 255, 255)End IfIf vValue = "AT" ThenTarget.Interior.Color = RGB(255, 255, 0)End IfIf vValue = " " ThenTarget.Interior.Color = RGB(0, 0, 0)End IfIf vValue = "l" ThenTarget.Interior.Color = RGB(0, 255, 0)End IfIf vValue = "ce" ThenTarget.Interior.Color = RGB(205, 204, 153)End IfIf vValue = "xe" ThenTarget.Interior.Color = RGB(153, 153, 255)End IfIf vValue = "hg" ThenTarget.Interior.Color = RGB(255, 102, 0)End IfIf vValue = "sg" ThenTarget.Interior.Color = RGB(0, 255, 255)End IfIf vValue = "at" ThenTarget.Interior.Color = RGB(255, 255, 0)End IfIf vValue = "d" ThenTarget.Interior.Color = RGB(255, 0, 0)End IfEnd Sub "However, what i would like to happen is for the cell to return to having no shading (or revert to white) when the contents of the cell is deleted.If there is anyone who can help me with this, it would be hugely appreciated.Thank youRegardsArran