ExcelNooberino
New Member
- Joined
- Jan 2, 2019
- Messages
- 43
- Office Version
- 2016
- Platform
- Windows
Hello guys!
I have this UserForm I've created and it has some ListBoxes where I am .Adressing the range from a different sheet, the thing is, it works just fine if I just want to show one unique range all the time. It happens that I need it to show different sheet ranges when I click different buttons that I've created on the main sheet. For example, this is what I have on the UserForm code:
With this it perfectly shows the range that I'm adressing but is there a way I can create differente "Initializes" for the same UserForm in a way that I can call them from different buttons?! Thanks in advance!
I have this UserForm I've created and it has some ListBoxes where I am .Adressing the range from a different sheet, the thing is, it works just fine if I just want to show one unique range all the time. It happens that I need it to show different sheet ranges when I click different buttons that I've created on the main sheet. For example, this is what I have on the UserForm code:
Code:
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
Dim LastRow As Long
Dim wb As Workbook
Dim wsTemp As Worksheet
Set wb = ThisWorkbook
Set wsTemp = wb.Sheets("VW428")
LastRow = Sheet2.Range("K" & Rows.Count).End(xlUp).row
wb.Sheets("VW428").Activate
With ListBox1
.ColumnCount = 3
.ColumnWidths = "73;230;25"
.RowSource = wsTemp.Range("I5:K" & LastRow).Address
End With
With ListBox2
.RowSource = wsTemp.Range("A1").Address
End With
wb.Sheets("Dashboard").Activate
Application.ScreenUpdating = True
End Sub
With this it perfectly shows the range that I'm adressing but is there a way I can create differente "Initializes" for the same UserForm in a way that I can call them from different buttons?! Thanks in advance!