Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have this userform initialization code:
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.
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.