ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not getting hoped for result (https://www.excelbanter.com/excel-programming/408914-not-getting-hoped-result.html)

Patrick C. Simonds

Not getting hoped for result
 
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


JLGWhiz

Not getting hoped for result
 
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.

"Patrick C. Simonds" wrote:

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



Patrick C. Simonds

Not getting hoped for result
 
Thanks

"JLGWhiz" wrote in message
...
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.

"Patrick C. Simonds" wrote:

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




Dave Peterson

Not getting hoped for result
 
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.

"Patrick C. Simonds" wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com