Hi,
I have the next code that run well after I click on play button in VB editor.
I need that this code will run automatically after I opened my file.. I tried to copy it to "thisworkbook" tab at VB editor but Im getting repeated error that something is wrong.
What I miss here?
My code:
Option Explicit
Private Dic As Object
Private ws As Worksheet
Sub ComboBox21_Change()
If ws.AutoFilterMode Then ws.AutoFilterMode = False
ws.Range("A5:T5").AutoFilter 5, Me.ComboBox21.Value
End Sub
Sub UserForm_Initialize()
Dim Cl As Range
Set ws = Sheets("Sheet1")
Set Dic = CreateObject("scripting.dictionary")
Dic.comparemode = vbTextCompare
For Each Cl In ws.Range("E6", ws.Range("E" & Rows.Count).End(xlUp))
If Not Dic.Exists(Cl.Value) Then Dic.Add Cl.Value, Nothing
Next Cl
Me.ComboBox21.List = Dic.keys
End Sub
I have the next code that run well after I click on play button in VB editor.
I need that this code will run automatically after I opened my file.. I tried to copy it to "thisworkbook" tab at VB editor but Im getting repeated error that something is wrong.
What I miss here?
My code:
Option Explicit
Private Dic As Object
Private ws As Worksheet
Sub ComboBox21_Change()
If ws.AutoFilterMode Then ws.AutoFilterMode = False
ws.Range("A5:T5").AutoFilter 5, Me.ComboBox21.Value
End Sub
Sub UserForm_Initialize()
Dim Cl As Range
Set ws = Sheets("Sheet1")
Set Dic = CreateObject("scripting.dictionary")
Dic.comparemode = vbTextCompare
For Each Cl In ws.Range("E6", ws.Range("E" & Rows.Count).End(xlUp))
If Not Dic.Exists(Cl.Value) Then Dic.Add Cl.Value, Nothing
Next Cl
Me.ComboBox21.List = Dic.keys
End Sub