Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: click in cell and make it change color?

Ok VBA prgs....

I need this solution:

A person left clicks on a cell that already has text in it. I need
that cell to (1) change color, and (2) generate a value (in a different
cell) because the person clicked in the text cell (can be value of 1 or
0).

For example, in Column A, in cells 1-12 I write in the months of the
year. If a person clicks on the cell containing "March" (cell A3) I
want that cell to change to the color yellow, and in cell B3 the number
"1" is entered.

Any ideas?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how do I: click in cell and make it change color?

Jason,

Add this code to the worksheet code module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A1:A12")) Is Nothing Then
Range("A1:A12").Interior.ColorIndex = xlColorIndexNone
Target.Interior.ColorIndex = 6
Target.Offset(0, 1) = 1
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"jasonsweeney " wrote in
message ...
Ok VBA prgs....

I need this solution:

A person left clicks on a cell that already has text in it. I need
that cell to (1) change color, and (2) generate a value (in a different
cell) because the person clicked in the text cell (can be value of 1 or
0).

For example, in Column A, in cells 1-12 I write in the months of the
year. If a person clicks on the cell containing "March" (cell A3) I
want that cell to change to the color yellow, and in cell B3 the number
"1" is entered.

Any ideas?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: click in cell and make it change color?

Thank you very much that is helpful.

But I need the color to remain "on" once clicked, but if you click th
same cell again, then the color turns "off" (and the number als
dissapears).

Thus, in my example, if you select March, the cell turns yellow an
Cell B3 gets a "1." Then you select "January". Now there should b
two yellow cells, both with a "1" next to it. Now I click on "March
again and it turns back to no color, leaving only January yellow with
"1" next to it

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how do I: click in cell and make it change color?

Jason,

Okay try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A1:A12")) Is Nothing Then
If Target.Offset(0,1) = 1 Then
Target.Interior.Colorindex = xlColorindexNone
Target.Offset(0,1).Value = ""
Else
Target.Interior.ColorIndex = 6
Target.Offset(0, 1) = 1
End If
End If

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"jasonsweeney " wrote in
message ...
Thank you very much that is helpful.

But I need the color to remain "on" once clicked, but if you click the
same cell again, then the color turns "off" (and the number also
dissapears).

Thus, in my example, if you select March, the cell turns yellow and
Cell B3 gets a "1." Then you select "January". Now there should be
two yellow cells, both with a "1" next to it. Now I click on "March"
again and it turns back to no color, leaving only January yellow with a
"1" next to it.


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: click in cell and make it change color?

Perfect. Thanks a million.


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: click in cell and make it change color?

One problem:

I incorporated your code into the application I am working on....but
now I get an "Error 13" when I try and select more than one cell.....

still using my example, When I select March AND February at the same
time in one selection, I get an error 13.


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Theme color doesn't change when I click it? Rachey Excel Worksheet Functions 1 March 5th 08 09:30 PM
can u make a text in a cell to blink , or change it's color? kbee Excel Worksheet Functions 2 February 15th 08 07:40 PM
make cell color change if requirements are met? PMLACC Excel Discussion (Misc queries) 2 July 14th 06 10:01 PM
Stumped: If a cell contains a formula, can you make text color automatically change? qwopzxnm Excel Worksheet Functions 7 April 5th 06 04:07 AM
Change cell back color on click Dave Peterson Excel Discussion (Misc queries) 0 January 24th 05 10:50 PM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"