Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
garr
 
Posts: n/a
Default Change color in cells

When I click on a particular cell i want it to change to a particular color
and when i click on it again i want it to change back to the original color
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Change color in cells

Here is one way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
When I click on a particular cell i want it to change to a particular

color
and when i click on it again i want it to change back to the original

color


  #3   Report Post  
Posted to microsoft.public.excel.misc
garr
 
Posts: n/a
Default Change color in cells

I guess I didn't explain very good what I wanted. but here goes again
Cell is white
Click on cell
Cell changes to color (orange) and stays the color
Click on cell again
Cell changes back to white
or
Click on cell
Cell changes to color (Green) and stays the color
Click on cell again
Cell changes to white

I would like to work with two colors
I want to be able to do this with any cell.

"Bob Phillips" wrote:

Here is one way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
When I click on a particular cell i want it to change to a particular

color
and when i click on it again i want it to change back to the original

color



  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Change color in cells

Okay, but this gives some interesting effects

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Const iColor As Long = 10

With Target.Interior
If .ColorIndex = iColor Then
.ColorIndex = xlColorIndexNone
Else
.ColorIndex = iColor
End If
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
I guess I didn't explain very good what I wanted. but here goes again
Cell is white
Click on cell
Cell changes to color (orange) and stays the color
Click on cell again
Cell changes back to white
or
Click on cell
Cell changes to color (Green) and stays the color
Click on cell again
Cell changes to white

I would like to work with two colors
I want to be able to do this with any cell.

"Bob Phillips" wrote:

Here is one way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
When I click on a particular cell i want it to change to a particular

color
and when i click on it again i want it to change back to the original

color





  #5   Report Post  
Posted to microsoft.public.excel.misc
garr
 
Posts: n/a
Default Change color in cells

Is there a way to add ctl or alt and click to do this

"Bob Phillips" wrote:

Okay, but this gives some interesting effects

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Const iColor As Long = 10

With Target.Interior
If .ColorIndex = iColor Then
.ColorIndex = xlColorIndexNone
Else
.ColorIndex = iColor
End If
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
I guess I didn't explain very good what I wanted. but here goes again
Cell is white
Click on cell
Cell changes to color (orange) and stays the color
Click on cell again
Cell changes back to white
or
Click on cell
Cell changes to color (Green) and stays the color
Click on cell again
Cell changes to white

I would like to work with two colors
I want to be able to do this with any cell.

"Bob Phillips" wrote:

Here is one way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
When I click on a particular cell i want it to change to a particular
color
and when i click on it again i want it to change back to the original
color








  #6   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Change color in cells

You could maybe use the BeforeDoubleClick event.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
Is there a way to add ctl or alt and click to do this

"Bob Phillips" wrote:

Okay, but this gives some interesting effects

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Const iColor As Long = 10

With Target.Interior
If .ColorIndex = iColor Then
.ColorIndex = xlColorIndexNone
Else
.ColorIndex = iColor
End If
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
I guess I didn't explain very good what I wanted. but here goes again
Cell is white
Click on cell
Cell changes to color (orange) and stays the color
Click on cell again
Cell changes back to white
or
Click on cell
Cell changes to color (Green) and stays the color
Click on cell again
Cell changes to white

I would like to work with two colors
I want to be able to do this with any cell.

"Bob Phillips" wrote:

Here is one way

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

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.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"garr" wrote in message
...
When I click on a particular cell i want it to change to a

particular
color
and when i click on it again i want it to change back to the

original
color








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
have a name change cells between sheets Michele Excel Worksheet Functions 0 March 23rd 06 10:43 PM
Change the color of cells in the pivot table minrufeng Excel Discussion (Misc queries) 0 March 14th 06 08:18 PM
Change the color of some cells in the pivot table minrufeng Excel Discussion (Misc queries) 0 March 14th 06 08:17 PM
I Need to change reference sheet for all cells on a form Brent E Excel Discussion (Misc queries) 1 February 11th 05 01:36 AM
Change a cell's fill color dynamically? Arlen Excel Discussion (Misc queries) 2 January 22nd 05 09:51 PM


All times are GMT +1. The time now is 12:52 PM.

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

About Us

"It's about Microsoft Excel"