Hi All,
I'm new here. I need help on the below
I have a ComboBox1 defined in sheet (“ABC”). This combo will call a Sub in Module 2 to assign the selection list for the combobox plus other tasks. This is works fine.
Sheet(“ABC”)
Option Explicit
Private Sub ComboBox1_Change()
Application.EnableEvents = False
…..
Application.Run "Module2.AssignSelectionList"
…..
End Sub
Module 2
Option Explicit
Sub AssignSelectionList()
Dim SelectionArray As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Worksheets("ABC").ComboBox1.List = SelectionArray
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
But when user try to copy sheet (“ABC”) to multiple sheets, for example Sheet(“ABC (2)”), Sheet(“ABC(3)”) and so on, the above VBA will not work. So I have to define make worksheet name as variable as per below in Module 2. All the sheets will have a combobox named Combobox1.
Sheet(“ABC”)
Option Explicit
Private Sub Worksheet_Activate()
ActiveWs = ThisWorkbook.ActiveSheet.Name
End Sub
Private Sub ComboBox1_Change()
Application.EnableEvents = False
…..
Application.Run "Module2.AssignSelectionList"
…..
End Sub
Module 2
Option Explicit
Public ActiveWS as
Sub AssignSelectionList()
Dim SelectionArray As Variant
Dim Ws1 As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Set Ws1 = Worksheets(ActiveWs)
Ws1.ComboBox1.List = SelectionArray
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
This is not works! I have a compile error: Method or data member not found.
Thank you in advance.
Bookmarks