Auto-select answers on a form based on a previous answer.

VBAExcellNoob

Board Regular
Joined
Feb 13, 2015
Messages
117
Hello,

I have a form that has 10 combo boxes. The options in the combo boxes is "Yes", "No", "N/A".

If I select "Yes" for the first combo box is it possible that the next 5 boxes automatically populate with "Yes"?

I've tried googling this but haven't had much success.

If anyone has any ideas please let me know.

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Let's say the names of your 10 Combo Boxes are Combo1 - Combo10.

Then, in the AfterUpdate event of Combo1, add this VBA code:
Code:
Private Sub Combo1_AfterUpdate()

    If Me.Combo1 = "Yes" Then
        Me.Combo2 = "Yes"
        Me.Combo3 = "Yes"
        Me.Combo4 = "Yes"
        Me.Combo5 = "Yes"
        Me.Combo6 = "Yes"
    End If
    
End Sub
 
Last edited:
Upvote 0
Try this:

Put this script in combobox1


Code:
Private Sub ComboBox1_Change()
If ComboBox1.Value = "Yes" Then
Dim i As Long
    For i = 2 To 6
        Me.Controls("Combobox" & i).Value = "Yes"
    Next
Else
    For i = 2 To 6
        Me.Controls("Combobox" & i).Value = ""
    Next
End If
End Sub

Not sure if you then change combobox1 back to No what you want to happen. This script will set them to nothing. If you don't want that then remove the else statement.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,713
Messages
6,161,463
Members
451,708
Latest member
PedroMoss2268

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