Want I am trying to do is create a summary, where I want to count all the instances a name appears between a certain date range, where the value is "Yes" in another column.
The problem I am having is that this will be sent to more than 1 user group and the names will be different. So I want to use a combobox to determine the names.
here is a bit of my code so far
This is set up fine to return the count for 1 specific name. However I need to return a count for each name in the list cboName, and offset the range posted to by (1,0) each time.
Thinking I might need another loop somewhere, and I thought I'd use listindex (which is why I have Dim X As String in my code), but can't figure it out
The problem I am having is that this will be sent to more than 1 user group and the names will be different. So I want to use a combobox to determine the names.
here is a bit of my code so far
Code:
Sub Summary()
Dim rng As Range, _
rng1 As String, _
ws1 As Worksheet, _
ws2 As Worksheet, _
Count As Long, _
lngLastRow As Long, _
DF As String, _
DT As String, _
findoffset As Long, _
X As String
DF = Format(CDate(Sheets("MainMenu").txtFrom.Value), "dd/mm/yyyy")
DT = Format(CDate(Sheets("MainMenu").txtTo.Value), "dd/mm/yyyy")
lngLastRow = Sheets("Data").Cells(Rows.Count, "M").End(xlUp).Row
X = 0
Set ws1 = Sheets("Data")
Set ws2 = Sheets("Summary")
Count = 0
With ws1.Range("M3:M" & lngLastRow)
Set rng = .Find("Yes", LookIn:=xlValues)
If Not rng Is Nothing Then
rng1 = rng.Address
Do
If Format(CDate(rng.Offset(, -8)), "dd/mm/yyyy") >= DF And Format(CDate(rng.Offset(, -8)), "dd/mm/yyyy") < DT Then
If rng.Offset(, 11) = Sheets("MainMenu").cboName.Value Then
Count = Count + 1
End If
End If
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address <> rng1
End If
End With
ws2.Range("F5").Value = Count
End Sub
This is set up fine to return the count for 1 specific name. However I need to return a count for each name in the list cboName, and offset the range posted to by (1,0) each time.
Thinking I might need another loop somewhere, and I thought I'd use listindex (which is why I have Dim X As String in my code), but can't figure it out