Verify that a button has been selected

Solved
Villette54 Posted messages 300 Registration date   Status Member Last intervention   -  
Villette54 Posted messages 300 Registration date   Status Member Last intervention   -
Hello,

I need a little help. Actually, I have on my USF 2 an “optionbutton,” namely optionbutton1 and optionbutton2.

I’d like to add to my macro (which sends an email when you click validate) a step to verify that one of these two buttons has been checked. If one of them is checked, okay, we proceed. Otherwise a MsgBox asks to make a choice.

I’ve tried several approaches but can’t get it to work properly. I was thinking of something like:

If CommandButton2 = False And CommandButton1 = False Then MsgBox ("Veuillez choisir s'il s'agit d'un bug ou d'une amélioration")
Else GoTo Fin
End If

But that doesn’t work... For info I’m new to VBA, sorry if the error is obvious.

Thanks in advance.

7 answers

  1. Villette54 Posted messages 300 Registration date   Status Member Last intervention   28
     
    In short, you ask pointless questions for which you already have the answers.

    Indeed I’ve been asking questions about VBA for a while now, but that doesn’t change the fact that it’s a tool I use very occasionally. So obviously I’m a beginner, and yes I need help, but not yours.

    So go waste your time elsewhere than on my topics. Thanks
    1
  2. Villette54 Posted messages 300 Registration date   Status Member Last intervention   28
     
    I’m not angry, but I’m tired of your repetitive messages on ALL of my topics.

    I know very well that you helped me with my initial requests, and I thank you for that. But since then you keep coming onto my topics, without contributing anything. So let’s just say that I don’t need your help anymore.

    With resentment, hoping I won’t have to deal with you again.
    Have a good day.
    1
  3. michel_m Posted messages 18903 Registration date   Status Contributor Last intervention   3 320
     
    Hello

    You have "optionbutton" and your code references "commandbutton"

    --
    Michel
    0
    1. Villette54 Posted messages 300 Registration date   Status Member Last intervention   28
       
      Hello Michel,

      Indeed, it is indeed an error in the code I am using the "optionbutton"
      Even after this correction, the code still doesn't work.

      For info, I did put the label End: at the end of my procedure.
      0
    2. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
       
      Hello everyone,

      test option buttons not checked

      If Not OptionButton1 And Not OptionButton2 Then
      x = x
      End If
      0
    3. Villette54 Posted messages 300 Registration date   Status Member Last intervention   28
       
      Hi f894009,

      It works perfectly.

      Thank you, and have a great rest of the day!
      0
  4. Villette54 Posted messages 300 Registration date   Status Member Last intervention   28
     
    Thank you for this comment very helpful as always.
    0
  5. Zoul67 Posted messages 2001 Status Member 149
     
    Hello,

    how long have you been starting with VBA?! o_O

    See you later
    -1
  6. Zoul67 Posted messages 2001 Status Member 149
     
    I waited for Michel_m to respond so that you would have something constructive.
    it amuses me (maybe only me) to invoke the beginner's argument when in March you were already posting questions about VBA.

    PS: I already suspect you’ll respond that you don’t do VBA all day long.
    -1
  7. Zoul67 Posted messages 2001 Status Member 149
     
    You seem really tense... And for the record, yes, you have already needed my help. No hard feelings
    -1