Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Single command to toggle a Boolean?

In Excel 2000 VBA, is there one single command to toggle a Boolean - that
is, in whatever state it's in, change it to the opposite? I know it can be
done with an If / Else - I was just wondering if there was a singe-line way
to do it.

Ed


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Single command to toggle a Boolean?

Ed wrote:
In Excel 2000 VBA, is there one single command to toggle a Boolean - that
is, in whatever state it's in, change it to the opposite? I know it can be
done with an If / Else - I was just wondering if there was a singe-line way
to do it.

Ed



----------------

Dim Flag as Boolean
Flag = not(Flag)

Bill
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Single command to toggle a Boolean?

Ed,

Use the Not operator. This will switch a boolean to its opposite.
E.g,

Dim Var As Boolean Dim Var As Boolean
Var = Not Var


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ed" wrote in message
...
In Excel 2000 VBA, is there one single command to toggle a
Boolean - that
is, in whatever state it's in, change it to the opposite? I
know it can be
done with an If / Else - I was just wondering if there was a
singe-line way
to do it.

Ed




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Single command to toggle a Boolean?

I have no idea how I got two Dim statements in the code. The
code should have only one Dim Statement.

Dim Var As Boolean
Var = Not Var


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
Ed,

Use the Not operator. This will switch a boolean to its
opposite. E.g,

Dim Var As Boolean Dim Var As Boolean
Var = Not Var


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ed" wrote in message
...
In Excel 2000 VBA, is there one single command to toggle a
Boolean - that
is, in whatever state it's in, change it to the opposite? I
know it can be
done with an If / Else - I was just wondering if there was a
singe-line way
to do it.

Ed






  #5   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Single command to toggle a Boolean?

Thanks, Chip.

"Chip Pearson" wrote in message
...
I have no idea how I got two Dim statements in the code. The
code should have only one Dim Statement.

Dim Var As Boolean
Var = Not Var


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
Ed,

Use the Not operator. This will switch a boolean to its
opposite. E.g,

Dim Var As Boolean Dim Var As Boolean
Var = Not Var


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ed" wrote in message
...
In Excel 2000 VBA, is there one single command to toggle a
Boolean - that
is, in whatever state it's in, change it to the opposite? I
know it can be
done with an If / Else - I was just wondering if there was a
singe-line way
to do it.

Ed










  #6   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Single command to toggle a Boolean?

Thanks, Bill.

"Bill Martin" wrote in message
...
Ed wrote:
In Excel 2000 VBA, is there one single command to toggle a Boolean -

that
is, in whatever state it's in, change it to the opposite? I know it can

be
done with an If / Else - I was just wondering if there was a singe-line

way
to do it.

Ed



----------------

Dim Flag as Boolean
Flag = not(Flag)

Bill



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
Command button to toggle worksheet event code on / off? Fred[_2_] Excel Discussion (Misc queries) 15 July 31st 07 11:50 AM
Boolean comparison: range vs. single cell msimms Excel Worksheet Functions 4 January 12th 06 12:50 AM
Toggle command buttons GEB Excel Programming 4 June 23rd 05 08:33 PM
Toggle multiple values in single cell Chandni Excel Worksheet Functions 5 February 10th 05 12:48 AM
Single command button to select one of several choices. Mike Krumel Excel Programming 6 July 18th 03 01:43 PM


All times are GMT +1. The time now is 03:16 PM.

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"