Hello. Help me please. There is a UserForm with two switches ( OptionButton ) and, of course, a start button. How to make it so that when you select one of the switches, the program, let's say, inserts a certain digit into a certain cell? I can not find the documentation on this issue. Thank you in advance.

    2 answers 2

    Like that:
    Let the form have two switches obOptionButton1 and obOptionButton2 . Add click event handlers for them, this is done very simply, in the form code you need to define the functions obOptionButton1_Click and obOptionButton2_Click respectively:

     Private Sub obOptionButton1_Click() If obOptionButton1.Value Then 'действия при выборе obOptionButton1 ActiveWorkbook.Sheets("Имя_Листа").Activate Range("A1").Value = "Значение ячейки в любом формате" End If End Sub 

    More details can be found here .

      Addition: as I understand it, the start button is intended to start the recording procedure, therefore:

       Private Sub CommandButton1_Click() 

      To insert a value, it is not necessary to activate the sheet.