So what I wanted to achieve is when someone clicks a certain year inside the combo box (which is located near cell A1 in my worksheet), a macro runs according to the year that was clicked. I want the list items to be stored in VBA code itself, rather than selecting them on the worksheet (I haven't found a single tutorial about combo box that doesn't use worksheet data).
I have created a button to load the data into the ComboBox1.
This is the code for now (I'm not trying to stick to it strictly, so if there's an easier way to write this, please let me know):
Sub Button1_Click()
Sheets("MacroBase").ComboBox1.List = Array("2015", "2016", "2017", "2018", "2019")
End Sub
Sub ComboBox1_GotFocus()
With ThisWorkbook.Sheets("MacroBase").Shapes("ComboBox1").ControlFormat
Select Case .List(.Value)
Case "2015": ShowOnly2015Columns
Case "2016": ShowOnly2016Columns
Case "2017": ShowOnly2017Columns
Case "2018": ShowOnly2017Columns
Case "2019": ShowOnly2019Columns
End With
End Sub
I didn't paste the code for ShowOnly####Columns (tested and running without problems).
Currently the _GotFocus doesn't work.
I thank in advance for all your time and help :)