I have one Excel sheet, one userform and a listbox is in userform. Now when i filter my sheet and update listbox by click on button that is on my user form i see all rows in lis
update of Shai Rado code as this will get ride of any blanks that would be populated in the combox
Private Sub ComButton_click
Dim cell As Range
Dim MyArr As Variant, i As Long
' intialize array to high number of elements at start
ReDim MyArr(0 To 10000)
' work on sheets "NEWPRJ" according to PO
With Sheets("Booking in")
' scan each cell in Range "D7:D46" only on visible cells (cells that are visible after the filter was applied)
For Each cell In .Range("D6:D10000").SpecialCells(xlCellTypeVisible)
'this was the if statement I added
If cell.Value = "" Then
MyArr(i) = cell.Value '
i = i
Else
MyArr(i) = cell.Value ' read all visible cells to array
i = i + 1
End If
Next cell
' reduce array size to populated elements only
ReDim Preserve MyArr(0 To i - 1)
' populate listbox with array
Findwork_Uf.ColumnD_Menu.List = MyArr
End With
Endsub
It was only the if statment i added to get rid of any blanks in the combobox drop down list.