1

I have created A userform with few command buttons.

I can't seem to figure out how do I get the information from them.

I want to open this userform from another one and then I want the user to choose an option from one of the buttons which will change a specific cell in the table itself

the userform I created

I did not write anything on this userform therefor there is no code from it to show only the design.

how do get the information from the buttons to be written in A specific cell on a specific worksheet?

Roy Shiff
  • 63
  • 7
  • Double click a button. This will take you to the code behind. You would put actions in the `_Click` events to do whatever you want. The form data is accessible from the code behind using the `Me.` object. – HackSlash Oct 14 '20 at 15:15
  • Then read this: https://stackoverflow.com/help/how-to-ask – HackSlash Oct 14 '20 at 15:16

1 Answers1

0

double click on one of the buttons, in the code menu a new sub should appear. this looks something like:

Sub CommandButton1_onClick()
End sub

Alongside this event method, it also has a few properties. The one that is usefull here is the CommandButton1.Value, this represents the state of the button (either true or false iirc).

So build for each button (I strongly advice giving them custom names to prevent getting lost in the trouble) as sub like this:

Sub CommandButton1_onClick()
   if CommandButton1.Value then
      ThisWorkBook.WorkSheets("WorksheetName").Range("YourRange").Value = "Some value"
   else
      ThisWorkBook.WorkSheets("WorksheetName").Range("YourRange").Value = ""
   end if
End sub
Petrus1904
  • 183
  • 7