micro for multi colors in a cell

  • Thread starter Thread starter jladika
  • Start date Start date
J

jladika

hi
i am very new to this and need some help with setting up a micro

I have a spreadsheet with a cell that i will have 4 options

"A" "B" "C" "D"

and i would like for each of them to have a different color when pu
into that cell.

Please i am new to this so you will have to walk me through the step
 
What I am providing is an event procedure. If placed in the proper cod
section (sheet code), it will run whenever a value is changed on th
worksheet. Right click the worksheet tab you wish to run it on, selec
view code and paste this there:


Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count = 1 Then
If Target.Address = "$A$1" Then
Select Case Target.Value
Case "A"
Target.Interior.ColorIndex = 33
Case "B"
Target.Interior.ColorIndex = 34
Case "C"
Target.Interior.ColorIndex = 35
Case "D"
Target.Interior.ColorIndex = 36
Case Else
Target.Interior.ColorIndex = 0
End Select
End If
End If

End Su
 
Maybe you shouldn't use Excel? You already have gotten multiple instructions
how to setup a macro,
not only do you seem unable to grasp written instructions, you also break
all etiquette by posting multiple
times in different NGs.. Once again here is J.E's macro adapted for 4
colours

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = "A1" Then
Select Case .Value
Case "A"
.Font.ColorIndex = 4
Case "B"
.Font.ColorIndex = 3
Case "C"
.Font.ColorIndex = 46
Case "D"
.Font.ColorIndex = 5
Case Else
.Font.ColorIndex = xlColorIndexAutomatic
End Select
End If
End With
End Sub

now right click the sheet tab where you want this to happen, select view
code,
paste in the above, press Alt + Q to close the VBE and save the workbook,
test by putting A-D in A1 and press enter

--


For everyone's benefit keep the discussion in the newsgroup.

Regards,

Peo Sjoblom
 
well PEO

i am new to this and sorry about the multi time i posted
i though that if i posed it again and try to explain alittle differen
some will know how to help me.

i have tryed the way you said with pasting what you had sent to me bu
after that i didn know what to do
 
Excuse me for being sarcastic but you got about 15-16 answers to your posts
yesterday including
a couple telling you to keep to the same thread (since you multiposted
yesterday as well) and several with links how to install macros
or using conditional formatting..


--


For everyone's benefit keep the discussion in the newsgroup.

Regards,

Peo Sjoblom
 
what am i doing
how am i going out of the newsgroup
i dont know how i am doing that
please tell me so i wont do it again
thanks joe

as far as all the help
you gave me something that no one else did
after i pasted the it in the view code
i didnt know what to do next and you said
Press alt+Q to close
that was was missing in all the others
thanks again jo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top