COlor change macro

Closed
Rommy - Jan 21, 2011 at 10:17 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jan 22, 2011 at 12:18 AM
HI All,

I need an excel macro where i require to do the following things:


if i type RED then the cell in which i type RED turns red,
SImilarly if i type Purple then the cell turn purple
if i type yellow then the cell turns yellow,
if i type green then the cell turns green,
if i type blue then the cell turns blue,
if i type orange, then the cell turns orange,
if i type COMPLETED, then the cell remains white.


Please give me an excel macro for the above.

Thanks



1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jan 22, 2011 at 12:18 AM
open vb editor alt+F11 and hit control+R
in the project window right click shee1 of YOUR FILE
click view code and copy this event code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As String
 
 Target.Interior.ColorIndex = xlNone
 Select Case Target
 Case "red"
 Target.Interior.ColorIndex = 3
 Case "purple"
 Target.Interior.ColorIndex = 7
 Case "yellow"
  Target.Interior.ColorIndex = 6
  Case "green"
   Target.Interior.ColorIndex = 4
  Case "blue"
   Target.Interior.ColorIndex = 5
   
End Select



End Sub


type in any cell red and see what happens to that cell
try few more colors and some other cells

I do not what u mean by orange. find the number and add that case statement within the event code
0