Can a cell be turned on and off?

  • Thread starter Thread starter painter50
  • Start date Start date
P

painter50

My cell to like this

=(A2+A3) I would like this total to only be active if I click on the cell.

In other words can the cell be turned on or off by just clicking on it?
 
Not without using VBA

You want the value toggled on/off or just toggle the font white or black?

This event code will toggle the formula on or off.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const myRange As String = "A1"
On Error GoTo stoppit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then
With Target
If .Value = "" Then
.Formula = "=A2+A3"
Else
.Value = ""
End If
End With
End If
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP
 
Back
Top