I am currently using this code to place names in a combobox (active X). How can I use an array to perform each line to all 12 months without repeating the code over and over?
Here is what I have:
I have tried:
which is giving me a object doesnt support this property or method
and
which is giving me object required.
Here is what I have:
Code:
Sub auto_Open()
Sheets("FEB").ComboBox1.List = Array("ALL", "ACT", "ROF", "MM")
Sheets("FEB").ComboBox2.List = Array("ACTvsROF_2", "ACTvsPLN_2", "ACTvsLY_2", "ROFvsMM_2", "ROFvsLM_2", "ROFvsPLN_2", "ROFvsLY_2", "MMvsLM_2", "MMvsPLN_2", "MMvsLY_2")
Sheets("FEB").ComboBox3.List = Array("ACTvsROF_3", "ACTvsPLN_3", "ACTvsLY_3", "ROFvsMM_3", "ROFvsLM_3", "ROFvsPLN_3", "ROFvsLY_3", "MMvsLM_3", "MMvsPLN_3", "MMvsLY_3")
Sheets("FEB").ComboBox4.List = Array("ACTvsROF_4", "ACTvsPLN_4", "ACTvsLY_4", "ROFvsMM_4", "ROFvsLM_4", "ROFvsPLN_4", "ROFvsLY_4", "MMvsLM_4", "MMvsPLN_4", "MMvsLY_4")
Sheets("FEB").ComboBox5.List = Array("ACTvsROF_5", "ACTvsPLN_5", "ACTvsLY_5", "ROFvsMM_5", "ROFvsLM_5", "ROFvsPLN_5", "ROFvsLY_5", "MMvsLM_5", "MMvsPLN_5", "MMvsLY_5")
End Sub
I have tried:
Code:
Sheets(Array("FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC", "JAN")).ComboBox2.List = Array("ACTvsROF_2", "ACTvsPLN_2", "ACTvsLY_2", "ROFvsMM_2", "ROFvsLM_2", "ROFvsPLN_2", "ROFvsLY_2", "MMvsLM_2", "MMvsPLN_2", "MMvsLY_2")
and
Code:
Dim ws As Worksheet
For Each ws In Sheets(Array("FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC", "JAN"))
With ws
ComboBox1.List = Array("ALL", "ACT", "ROF", "MM")
End With
Next ws
which is giving me object required.
Last edited: