macro codes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
can anybody explain to me what does "not" do in the following code:

With Sheets("Sheet1").OptionButton1 'code name for the button
.Value = Not .Value
End With
thanks
 
The optionbutton's value can be true or false.

Not true = false
not false = true

The code toggles the optionbutton from checked to unchecked or vice versa.
 
The "Not" operator flips the bits, changing a 0 bit to a 1 bit. Generally,
you would use this only with TRUE and FALSE values to toggle between the two
(TRUE = NOT FALSE, FALSE = NOT TRUE), but it can be used with any number.
E.g.,

Not &h000000FF = &hFFFFFF00

If it is used with number other than -1 (TRUE) and 0 (FALSE), it would be
confusing and quite possibly wrong.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
thanx I got it.

Dave Peterson said:
The optionbutton's value can be true or false.

Not true = false
not false = true

The code toggles the optionbutton from checked to unchecked or vice versa.
 
thank you for your explanation.

Chip Pearson said:
The "Not" operator flips the bits, changing a 0 bit to a 1 bit. Generally,
you would use this only with TRUE and FALSE values to toggle between the two
(TRUE = NOT FALSE, FALSE = NOT TRUE), but it can be used with any number.
E.g.,

Not &h000000FF = &hFFFFFF00

If it is used with number other than -1 (TRUE) and 0 (FALSE), it would be
confusing and quite possibly wrong.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Back
Top