Thank you for your guide۰۰ can use ActiveSheet reference to refer to the current active sheet. This example will populate items from A1 to A5, from the sheet which is currently selected.
VBA Code:Private Sub UserForm_Initialize() ListBox1.List = ActiveSheet.Range("A1:A5").Value2 End Sub
Private Sub UserForm_Initialize()
ListBox1.List = ActiveSheet.ListObjects(1).DataBodyRange.Value2
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim k
k = Application.Match(Sh.Name, Array("Sheet1", "Sheet2"), 0)
If Not IsError(k) Then UserForm1.Show
End Sub
Private Sub UserForm_Initialize()
ListBox1.RowSource = ActiveSheet.ListObjects(1).Name
End Sub
Hello. See if the following is what you are looking for:
Hi,
VBA Code:Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim k k = Application.Match(Sh.Name, Array("Sheet1", "Sheet2"), 0) If Not IsError(k) Then UserForm1.Show End Sub
VBA Code:Private Sub UserForm_Initialize() ListBox1.RowSource = ActiveSheet.ListObjects(1).Name End Sub