Dim CountLng as Long
'Set CountLng to maximum row in column A that you would like to search for.
'This example uses the number of rows in the entire used range of the worksheet
CountLng = ActiveSheet.UsedRange.Rows.Count
With listbox1
' Loop over each cell in the column A
For x = 1 To CountLng
' If the cell is not blank then add it as a list item
If ActiveSheet.Range("A" & x).Value <> "" Then
.AddItem ActiveSheet.Range("A" & x).Value
End If
Next x
End With
1 回答
如何检查每个单元格中是否有值的循环: