wsnyder
Board Regular
- Joined
- Sep 23, 2018
- Messages
- 224
- Office Version
- 365
- Platform
- Windows
Hi all,
Using Excel 365.
My code returns an error when the source Table has 1 Row.
How can I modify to handle whether the Table has 1 to n Rows?
Works great as-is as long as the Table has 2 or more rows.
Thanks
-w
Using Excel 365.
My code returns an error when the source Table has 1 Row.
How can I modify to handle whether the Table has 1 to n Rows?
Works great as-is as long as the Table has 2 or more rows.
Thanks
-w
VBA Code:
Private Sub UserForm_Initialize()
'Objects
Dim wb As Workbook
Dim ws As Worksheet
Dim lo As ListObject
'Initialize
Set wb = ThisWorkbook
Set ws = wb.Worksheets("dataSuppliers")
Set lo = ws.ListObjects(1)
'Populate listbox
If lo.DataBodyRange.Rows.Count = 1 Then
'Do something
Else
lstBoxSuppliers.List = lo.DataBodyRange.Value
End If
'Tidy up
Set lo = Nothing
Set ws = Nothing
Set wb = Nothing
End Sub