View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default how to change cell colour by simply clicking on it

You could try this

put some autoshapes in C3, E3 and G3 as an example and fill colour them
yellow, red, and blue. Name them MMin3, MMin5, MMin7 and then add this code

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "C4:C20,E4:E20,G4:G20"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Interior.ColorIndex = xlColorIndexNone Then
.Interior.ColorIndex = Me.Shapes("MMin" &
..Column).Fill.ForeColor.SchemeColor - 7
Else
.Interior.ColorIndex = xlColorIndexNone
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


click a cell in columns C, E or G and see what happens.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"lovebunny" wrote in message
oups.com...
I am taking a computer course and needed to create an activity using
Excel. I put together an activity where Kindergarten students graph
M&M candies according to colour. What I would like to do is allow for
cells to change colour when a child clicks on it with the mouse. (e.g.
for each yellow M&M, the child is to click on cell in graph under the
pic of the yellow M&M. These cells would in turn change to
corresponding colour.)

I would also need to know how to have cell return to original colour
when clicked on twice- in case a mistake is made.

I have an example of what I want to do- see he

http://www.scs.sk.ca/cyber/elem/lear...s/rec_sht.html

Thank you in advance for your help- I am really new at this and
unfortunately can't figure this out on my own.

Jovette