Hi All
I have a list box in which I am trying to show names and email addresses from Sheets("Emails").Range("A:B")
Here is the userform_initialize code:
'##### Fills in email addresses ###############################################
Lastrow = ThisWorkbook.Sheets("Emails").Range("A" & ThisWorkbook.Sheets("Emails").Rows.Count).End(xlUp).Row
If IsEmpty(ThisWorkbook.Sheets("Emails").Range("A1").Value) Then
Else
With Menu.EmailsList
.ColumnCount = 2
.ColumnWidths = "45;95"
.RowSource = ThisWorkbook.Sheets("Emails").Range("A1:B" & Lastrow).Address
End With
End If
'##############################################################################
Display More
This basically checks if there are any names and addresses in the 'Emails" sheet, and if so populates the "EmailList" listbox on the userform "Menu".
But the code acts odd, for example if I'm currently on the "Emails" sheet in excel, then the code works fine, however if I am on the "Master" sheet (which is the only sheet the end users will ever see) then the listbox populates range("A1") on the master sheet, which is just a title and is completely not what I want.
I can't see where the listbox is getting this "Master" sheet reference from when populating, all the code clearly references ".RowSource = ThisWorkbook.Sheets("Emails").Range("A1:B" & Lastrow).Address"
What could be going on?
Regards