View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Show/Hide a Secret Cell


Change both occurrences of
Color.Index
to
ColorIndex

ColorIndex is all one word.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Hotbird" wrote in message
...
Many thanks for your suggestion Chip

I am using a very simple test spreadsheet - one page only called

"Sheet1",
with text "11" in cell A1 with both font and background colour

set grey.
There is no Module, but Sheet1 has the following code:

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
MsgBox "This Code is active 1"
Target.Font.Color.Index = 1 ' black text
Else
MsgBox "This Code is active 2"
Range("$A$1").Font.Color.Index = 15 'grey text
End If
End Sub

I click on cell A1, but unfortunately, get a run-time error

'424' saying
"Object Required" and the Debug window highlights in yellow the

line:
Target.Font.Color.Index=1. Have I missed something obvious?

Thank you again for taking the time to help.

"Chip Pearson" wrote in message
...
Try something like the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$3" Then
Target.Font.ColorIndex = 1
Else
Range("$C$3").Font.ColorIndex = 15
End If
End Sub

Put this code in the sheet module for the appropriate sheet.
Change $C$3 to the cell in question and change the 15 to the
correct colorindex value.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Hotbird" wrote in message
...
I am wondering if it would be possible to implement a

feature,
whereby a
cell which contains information hidden as grey text on a

grey
background,
could automatically change to black on grey in response to

mouse
movement
over the cell in question. There do not seem to be

standard
spreadsheet
events to trigger the 2 necessary macros.