Not getting hoped for result

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
P

Patrick C. Simonds

This code is using the current (active) Worksheet to provide the list data
not Friday Workshifts. Can any one tell me what I have missed?



Private Sub UserForm_Initialize()
With Worksheets("Friday Workshifts")
ListBox1.RowSource = "$A$2:$R$200"
End With
End Sub
 
Just include the sheet name that the rowsource is on as in the example:

Private Sub UserForm_Initialize()
With Worksheets("Friday Workshifts")
ListBox1.RowSource = "'SheetName'!$A$2:$R$200"
End With
End Sub

Requires the single quotes and the exclamation mark.
 
Thanks

JLGWhiz said:
Just include the sheet name that the rowsource is on as in the example:

Private Sub UserForm_Initialize()
With Worksheets("Friday Workshifts")
ListBox1.RowSource = "'SheetName'!$A$2:$R$200"
End With
End Sub

Requires the single quotes and the exclamation mark.
 
I'd use:

With Worksheets("Friday Workshifts")
me.ListBox1.RowSource = .range("$A$2:$R$200").address(external:=true)
End With

And not have to ever worry about the syntax.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top