Inputting multiple choices through buttons

srcastle

New Member
Joined
Jul 19, 2006
Messages
7
I have a worksheet which contains feedback scores for my company. I’ve set up user forms and command buttons to simplify the inputting.
For example, User form 1 says ‘How useful did you find the staff?’, and contains five command buttons, marked 1 to 5.
How do I get VBA to input the relevant value? ie if command box 3 is selected by the user, I need 3 entered into the next available row in column A?

Thanks for your help.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Wow -

Thanks for the quick reply. I don't much like the circular spot in the button, and I can't see how to remove it.

However - what would the code be for an option button?

Thanks again
 
Upvote 0
You would probably connect this to a Submit button.

Code:
Dim ArrayOfOptionButtons as Variant
Dim i As Long

ArrayOfOptionButtons = Array("null", OptionButton1, OptionButton2, OptionButton3, OptionButton4, OptionButton5)

For i = 1 to UBound(ArrayOfOptionButtons)
    If ArrayOfOptionButtons(i) Then 
      Sheet1.Columns(1).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = "Option " & i & " selected."
    End If
Next i
 
Upvote 0
In the end I did this:
A short 'Call' instruction for the command button -

Private Sub CommandButton1_Click()
Call Q1A1
Unload Me
Q2.Show
End Sub

Then Question 1, Answer 1 (Q1A1) -
Sub Q1A1()
Range("C3").Select
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
Selection.Value = 1
End Sub

Answer 2's value would be 2 etc.
This allowed for Yeses and Nos, too.

I know that I've ended up with far more code than many here would find ideal, but at my level of progamming skill (almost zero), I needed something simple!

Thanks for taking the time to help - it really is appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top