Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Toggle True/False in a cell

Dave's method is better, but just another idea...

With Range("A1")
If WorksheetFunction.IsLogical(.Item(1)) Then
.Value = Not .Value
End If
End With

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dave Peterson" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Cell D3 within 10% of B3 True or false? Mark B Excel Discussion (Misc queries) 13 September 16th 09 11:14 AM
Is Cell D3 within 10% of B3 True or false? Mark B Excel Discussion (Misc queries) 6 September 15th 09 04:29 PM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
Function to return True/False if all are validated as True by ISNU Tetsuya Oguma Excel Worksheet Functions 2 March 15th 06 10:28 AM
Use IF to change value in a different cell when TRUE (or FALSE)? Ricter Excel Discussion (Misc queries) 2 February 8th 06 11:54 PM


All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"