Estou realizando um tipo de filtro no qual eu especifico um variável string dentro do programa e depois seleciono a data máxima e mínima que teve ocorrência desta variável, mas ao realizar nem todas as vezes realizou a contagem de maneira certa, por favor
me ajudem...
Segue a programação
Dim a As Integer, b As Integer, Cont As Integer, D As Integer, E As Integer, F As Integer, G As Integer, H As Integer
Dim I As Integer, J As Integer, x As Integer, w As String
Private Sub cmdAnalisar_Click()
If txtDataInicial.Text = "" Then
MsgBox "Necessário inserir todos os Parâmetros", vbCritical, "Preencha os Parâmetros!"
ElseIf txtDataFinal.Text = "" Then
MsgBox "Necessário inserir todos os Parâmetros", vbCritical, "Preencha os Parâmetros!"
End If
VerificarUltimo
ContarValores
End Sub
Private Sub ContarValores()
x = 2
Do While Sheets("Relatorios").Cells(x, 1) <> ""
w = Sheets("Relatorios").Cells(x, 1).Text
b = 3
Cont = 0
Do While a > b
If w = Plan1.Cells(b, 8).Text And txtDataInicial.Text < Plan1.Cells(b, 7) And txtDataFinal.Text > Plan1.Cells(b, 7) Then
Cont = Cont + 1
End If
b = b + 1
Loop
Sheets("Relatorios").Cells(x, 2) = Cont
x = x + 1
Loop
End Sub
Private Sub txtDataInicial_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtDataInicial = Format(txtDataInicial, dd, mm, yyyy)
End Sub
Private Sub txtDataFinal_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtDataFinal = Format(txtDataFinal, dd, mm, yyyy)
End Sub
Private Sub cmdSair_Click()
End
End Sub
Private Sub VerificarUltimo()
a = Plan1.Cells(Rows.Count, 1).End(xlUp).Row + 1
End Sub