'vba set combobox value to multiple cells in multiple sheets

I have 3 combo-boxes and an OK button. I need to set the value of multiple cells in multiple worksheets equal to the value of the combo box selection.

Dim choice As String
Dim x As Variant

x = Array("STD BASE DD", "STD BASE CAB DOOR ONLY", "OPEN BASE CABINET", _
    "1 DRAWER BASE & OPEN", "2 DRAWER BASE", "3 DRAWER BASE", "4 DRAWER BASE", _
    "5 DRAWER BASE")
    
    choice = matsetup.ComboBox1.Value

   Worksheets(x).Range("H14,H15,H20").Value = choice

This gives an error "object doesn't support property or method".

Worksheets(x).Range("H14,H15,H20").Value = choice

Does anyone know a workaround?



Solution 1:[1]

Perhaps you're looking for something like this?

Dim choice As String
Dim x As Variant
Dim v As Variant

x = Array("STD BASE DD", "STD BASE CAB DOOR ONLY", "OPEN BASE CABINET", _
          "1 DRAWER BASE & OPEN", "2 DRAWER BASE", "3 DRAWER BASE", _
          "4 DRAWER BASE", "5 DRAWER BASE")

choice = matsetup.ComboBox1.Text

For Each v In x
    Worksheets(v).Range("H14,H15,H20").Value = choice
Next v

Solution 2:[2]

Does this work?

Worksheets(x).Range("H14").Value = choice
Worksheets(x).Range("H15").Value = choice
Worksheets(x).Range("H20").Value = choice

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tigeravatar
Solution 2 Dominique