I currently making an Excel VB application. However, I am stuck at the moment. I am trying to make the choice between two OptionButtons compulsory.
I tried the code
If Me.PWebOption.Value = False & Me.BWebOption = False Then
MsgBox "Please choose a type of website"
Exit Sub
End If
But this is not giving me the required results. I tried putting them in brackets and everything but still stuck. I’m sure this is a trivial answer but I am just getting to grips with VB so please forgive me.
Many thanks in advance.
I tried your code and it works if you change & to And. I created 2 OptionButtons, named them and ran the code with “And” without problems.
If it still doesn’t work then my guess is that:
or:
Try
It should all return false. Also try putting
Option Explicitat the head of your Code to ensure you are only accessing objects that actually exist.Note: In VBA & is only used for concatenation and: And, Or and Not are the logical operators.