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

A

abxy

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
 
E

Eileen

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.
 
C

Charles

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
 
B

Bob Phillips

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)
 
Top