Good afternoon all
I have a workbook with several tabs "FRONT, DATASHEET, NAMES, JOBS, PROCESSES"
everyone works from the "FRONT" tab
I have a button that brings up a user form with a combobox that gets its data from a list on tab "NAMES"
When i press the button the user form appears with the data but it also shows the "NAMES" sheet
i would like it to remain on the "FRONT" sheet whilst i use the userform
I know it has something to do with the Sheets("NAMES"). Activate command but i don't know how to fix it
i have fond this code online
any help would be grateful
Private Sub UserForm_Initialize()
Dim i As Long, lr As Long ' define the variables
Sheets("NAMES").Activate ' activate the sheet where you have the list to populate the combobox
lr = Sheets("NAMES").Range("C" & Rows.Count).End(xlUp).Row ' find last row based on the last cell with values form column A. you can use any other column
ComboBox1.Value = "" ' set values of combobox to nothing. this step will help avoiding double values
For i = 2 To lr 'loop from row 2 to last row find. you can replace last row with a fixed row. for example in this case 7.
With ComboBox1
.AddItem (Cells(i, 3).Value) ' populate the combobox with the values from cell i,3
End With
Next
End Sub
Bookmarks