ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quick VBA code question (if...then statement) (https://www.excelbanter.com/excel-programming/292602-quick-vba-code-question-if-then-statement.html)

abxy[_31_]

Quick VBA code question (if...then statement)
 
How would i write in VB code:

if checkbox1, checkbox2, and checkbox3 all equal false then Unload me
else finish going thru the rest of the code.

I just don't know how to 'ask' "if [multiple things] then" in VB

thank

--
Message posted from http://www.ExcelForum.com


Eileen[_3_]

Quick VBA code question (if...then statement)
 
If checkbox1.value = false and checkbox2.value = false and
checkbox3.value = false then
unload me
End If

If all the criteria isn't met, the "unload me" will be
skipped and the code following the "end If" will execute.

-----Original Message-----
How would i write in VB code:

if checkbox1, checkbox2, and checkbox3 all equal false

then Unload me,
else finish going thru the rest of the code.

I just don't know how to 'ask' "if [multiple things]

then" in VB

thanks


---
Message posted from http://www.ExcelForum.com/

.


Charles

Quick VBA code question (if...then statement)
 
abxy

try something like this

with userform1
if .checkbox1 and .checkbox2 and .checkbox3 = False then
unload me
exit sub ''this stops the macro
end if
end with

HTH

Charle

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Quick VBA code question (if...then statement)
 
I would use

If Not Checkbox1.Value Then
If Not Checkbox2.Value Then
If Not Checkbox3.Value Then
Unload Me
End If
End If
End If

This way, if 1 or 2 is set, the remaining tests are not executed.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"abxy " wrote in message
...
How would i write in VB code:

if checkbox1, checkbox2, and checkbox3 all equal false then Unload me,
else finish going thru the rest of the code.

I just don't know how to 'ask' "if [multiple things] then" in VB

thanks


---
Message posted from http://www.ExcelForum.com/




abxy[_32_]

Quick VBA code question (if...then statement)
 
This worked, thanks guys! big help


---
Message posted from http://www.ExcelForum.com/



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com