Hi
I have the following code to find the first occurance of a selected date (txtWeekCommencing)then check if that date corresponds to a selected department (Depot) then loop until both criteria are met.
The code is reading the selected date but not working to check the department.
What do you think is going wrong?
Thanks 
Private Function m_DoFind(Data As Range) As Long
'
' Find all occurances and store addresses in array
'
Dim rngFind As Range
Dim strFirstAddress As String
m_DoFind = 0 ' No finds
ReDim m_strFindAddresses(m_DoFind) As String
'run the search
With Data
Set rngFind = .Find(what:=txtWeekCommencing.Value, LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext)
'if the item is not found the user is informed and the textbox cleared
If Not rngFind Is Nothing And rngFind.Offset(0, 6) = Depot Then
strFirstAddress = rngFind.Address
Do
If rngFind.Address <> .Cells(1, 1).Address Then
' check we don't store row header details
m_DoFind = m_DoFind + 1
ReDim Preserve m_strFindAddresses(m_DoFind) As String
m_strFindAddresses(m_DoFind) = rngFind.Address
End If
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Offset(0, 6) = Depot And rngFind.Address <> strFirstAddress
Test = m_DoFind
End If
End With
End Function
Bookmarks