View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Herold Winter Herold Winter is offline
external usenet poster
 
Posts: 1
Default Toggle True/False in a cell

Hello Dave,

I have test your code and it works perfectly.
It is excactly what i needed.

Thank you very much for your quick reaction
--
Herold Winter


"Dave Peterson" schreef in bericht
...
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