Thread: Color macro
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Color macro

I don't think it's touching the borders (format|Cell|border).

But if you add fill colors to cells, then the gridlines
(tools|Options|view tab|gridlines)
will seem to disappear.

But that happens no matter how you apply that fill color.

Another good reason to not show the gridlines and use borders instead <bg.

Jim May wrote:

This (code) seems to be removing the grid/border lines. Can this be also
handled to maintain the original look, including the borders/grid lines
arounf the cell?

"Chip Pearson" wrote:

Right click the appropriate sheet tab, choose View Code, and paste in the
following:


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Address = "$A$1" Then '<<<< CHANGE ADDRESS
If Target.Interior.ColorIndex = 6 Then '<<< 6 = yellow
Target.Interior.ColorIndex = xlColorIndexAutomatic
Else
Target.Interior.ColorIndex = 6
End If
Cancel = True
End If
End Sub

Change the address from $A$1 to the appropriate cell and change the 6 to the
desired ColorIndex value (see VBA Help for a list of colors).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Little Penny" wrote in message
...
Is there a macro that will change the interior color of a cell on a
click or double click? And then change it back to the default if
clicked again. I want to be able to go back and forth.


Thanks



--

Dave Peterson