When adding items to a listbox, how do i avoid ones marked "Do Not Use" (DNU). This is where I am picking up my listbox contents:
If an item is marked DNU, this is stated in column A on each sheet.
Code:
Private Sub FillResults() Dim ws As Worksheet
Dim rngFound As Range
Dim strFirst As String
Dim strSearch As String
Dim strWSname As String
Dim Excludedsheets As Variant, GetSearchArray As Variant
Dim x As Variant
Dim l As Long
l = 1
On Error GoTo ErrorHandle
frmBookings.LbxExistBook.Clear
strSearch = frmBookings.cboMembName.Value
For Each ws In ActiveWorkbook.Sheets
Excludedsheets = Array("Homepage", " ", " ", "Trips", "Data", "First", "Last", "Members")
x = Application.Match(ws.Name, Excludedsheets, 0)
If IsError(x) Then
l = l + 1
Set rngFound = ws.Range("C:C").Find(strSearch, ws.Range("C4"), xlFormulas, xlWhole, xlByColumns)
If Not rngFound Is Nothing Then
strWSname = ws.Range("D2") & ", " & Format(ws.Range("g2"), "Ddd dd Mmm YYYY")
With frmBookings.LbxExistBook
.AddItem strWSname
End With
End If
End If
Next ws
Exit Sub
ErrorHandle:
If Err.Number = 9 Then
MsgBox ("Error")
Else
MsgBox (Err.Description)
End If '
End Sub
If an item is marked DNU, this is stated in column A on each sheet.