Error With Listbox in Userform Initialization

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this userform initialization code:

VBA Code:
Private Sub UserForm_Initialize()

    Dim lrng As Range
    Dim lrow As Long
    
    lrow = ws_thold.Range("B" & ws_thold.Rows.Count).End(xlUp).Row
    lrng = ws_thold.Range("B1:C" & lrow)
    
    With lbx_datesel
        .RowSource = lrng.Address(External:=True)
        .ColumnHeads = False
        .ColumnWidths = "110;28"
    End With

End Sub

When I run this code, I get an "Object variable or With block variable not set" error. If I set through the code, I get the error after lrng =ws_thold.range("B1:C" & lrow)
lbx_datesel is the name of a listbox on my userform.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Thank you. Sometimes the obvious are so hidden.
 
Upvote 0

Forum statistics

Threads
1,215,824
Messages
6,127,087
Members
449,358
Latest member
Snowinx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top