View Single Post
  #3   Report Post  
aftamath
 
Posts: n/a
Default

That worked great, it was what I was looking for, but what's the syntax if I
want the same thing for a range of cells, say $B$6:$D$12, instead of one
column?

"David McRitchie" wrote:

A selection change would be the closest match for that, I would suggest
using a double-click event.

More information in
http://www.mvps.org/dmcritchie/excel/event.htm

To install right click on the sheet tab, View Code, plop the following code in.
This is setup to toggle value in Column 1 on a double-click, but you can modify code.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
Cancel = True 'Get out of edit mode
If Target.Column = 1 Then
If Trim(Target.Value) = "" Then
Target.Value = "X"
ElseIf UCase(Target.Value) = "X" Then
Target.Value = ""
Else
MsgBox "Cannot toggle switch in " & Target.Address(0, 0)
End If
End If
End Sub

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"aftamath" wrote in message ...
i would like to click on a cell in a worksheet and have the string value "X"
either inserted or removed from that cell upon clicking. Is this possible?