Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90214

Populate a listbox using a loop while ignoring blanks

$
0
0

I am trying to populate a listbox using items in column P and I would like to ignore the blanks.

Private Sub UserForm_Initialize()
    Dim strItem As String
    Dim i As Long
    For i = 1 To 500

        If Cells(i, 16).Value = "" Then

        Else
            strItem = Selection.Value
            Debug.Print strItem
            lbxItems.AddItem strItem.Value

        End If


End Sub

When I populate the listbox it all shows as blank. I expected it to be populated with the items in the column.


Viewing all articles
Browse latest Browse all 90214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>