ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not getting the result I was hoping for (https://www.excelbanter.com/excel-programming/408913-not-getting-result-i-hoping.html)

Patrick C. Simonds

Not getting the result I was hoping for
 
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


Mike

Not getting the result I was hoping for
 
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim curCell As Variant
Dim r As Long
Set ws = Worksheets("Friday Workshifts")
ListBox1.Clear
For r = 2 To 200
Set curCell = ws.Range("A" & r)
If Not IsEmpty(curCell) Then
ListBox1.AddItem (curCell)
End If
Next
End Sub

"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




All times are GMT +1. The time now is 07:32 PM.

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