Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
How do I format cells to reveal or hide contents when clicked?
Please help, I am trying to create a game for maths lessons. How do I set a
cell so that it's contents appear when I click once, then disappear on the next click? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
How do I format cells to reveal or hide contents when clicked?
How about double-click??
Put the following event macro in the worksheet code area: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Cancel = True With Target.Font If .ColorIndex = xlAutomatic Then .ColorIndex = 2 Else .ColorIndex = xlAutomatic End If End With End Sub This assumes that the backgound color of a cell is white. The first double-click on a cell changes the font to white, the second double-click on that cell changes the font color to black. Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200823 "Nanne" wrote: Please help, I am trying to create a game for maths lessons. How do I set a cell so that it's contents appear when I click once, then disappear on the next click? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
How do I format cells to reveal or hide contents when clicked?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const myRange As String = "A1:A10" On Error GoTo endit Application.EnableEvents = False Me.Unprotect Password:="justme" If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then With Me.Range(myRange).Cells .FormulaHidden = True .Locked = False End With With Target If .NumberFormat = ";;;" Then .NumberFormat = General Else .NumberFormat = ";;;" End If End With End If endit: Me.Protect Password:="justme" Application.EnableEvents = True End Sub Gord Dibben MS Excel MVP On Mon, 5 Jan 2009 08:59:00 -0800, Nanne wrote: Please help, I am trying to create a game for maths lessons. How do I set a cell so that it's contents appear when I click once, then disappear on the next click? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cell contents not recognised untill clicked | Excel Discussion (Misc queries) | |||
auto highlighting of cells when clicked on | Excel Discussion (Misc queries) | |||
set up a macro in Excel to color cells when clicked | Excel Worksheet Functions | |||
Can I format a cell to fill red when clicked with mouse (Excel)? | Excel Worksheet Functions | |||
Ho do I reveal the hidden format codes? | Excel Worksheet Functions |