View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Toggle True/False in a cell

How about this:

Option Explicit

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

If Target.Cells.Count 1 Then Exit Sub
If Target.Column < 7 Then Exit Sub

On Error GoTo errHandler:
Application.EnableEvents = False
Cancel = True
If TypeName(Target.Value) = "Boolean" Then
Target.Value = Not Target.Value
ElseIf IsEmpty(Target.Value) Then
Target.Value = True
End If

errHandler:
Application.EnableEvents = True

End Sub

Rightclick on the the worksheet tab that should have this behavior. Select View
Code and paste this in.

The macro looks for a rightclick when you're in column 7 (G). Modify that if
required.

Herold Winter wrote:

Hello,

I would like to know if the following is possible:

If you click on a cell the value will toggle between true or false.
I want to add a column which has that kind of cells.
I want to use it for marking purposes.

Sorry, for my bad englisch

--
Herold Winter


--

Dave Peterson