View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Toggle cell value

Right-click the sheet tab and choose View Code. In that code module,
paste the following code. Change the "$A$1" value to the address of
the cell you want to toggle.


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Address = "$A$1" Then '<<< CHANGE ADDRESS
Application.EnableEvents = False
Cancel = True
If StrComp(Target.Text, "apples", vbTextCompare) = 0 Then
Target.Value = "oranges"
Else
Target.Value = "apples"
End If
Application.EnableEvents = True
End If
End Sub

Now, when you double-click on A1, it will toggle between "apples" and
"oranges".


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Fri, 20 Feb 2009 00:00:02 -0800, Ken G.
wrote:

Is there a way of making a cell active so that it can have two values - say
"apples" and "oranges", and simply clicking on the cell will toggle between
the two values?