Combinar una macro que realize acción a base de dos criterios
Tengo esta macro que dante realizo correctamente ala necesidad
Set h1 = Sheets("history")
Set h2 = Sheets("temp")
h2.Cells.Clear
j = 2
For I = 2 To h1.Range("B" & Rows.Count).End(xlUp).Row
If h1.Cells(I, "B") = (Label10.Caption) And _
(h1.Cells(I, "K")) = "ENTREGADO" Then
folio = h1.Cells(I, "C")
Set b = h2.Columns("A").Find(folio, lookat:=xlWhole)
If b Is Nothing Then
h2.Cells(j, "A") = folio
j = j + 1
End If
End If
Next
u = h2.Range("A" & Rows.Count).End(xlUp).Row
res = WorksheetFunction.Count(h2.Range("A2:A" & u))
HISTORIAL.Label37.Caption = HISTORIAL.Label10.Caption & " SERVICIOS ENTREGADOS: " & res
Cuenta los "ENTREGADOS" a base de dos criterios lo que necesito es algo como esto:
Set h1 = Sheets("history")
Set h2 = Sheets("temp")
h2.Cells.Clear
j = 2
For I = 2 To h1.Range("B" & Rows.Count).End(xlUp).Row
If h1.Cells(I, "B") = (Label10.Caption) And _
(h1.Cells(I, "K")) = "ENTREGADO" Then
folio = h1.Cells(I, "C")
Set b = h2.Columns("A").Find(folio, lookat:=xlWhole)
If b Is Nothing Then
h2.Cells(j, "A") = folio
j = j + 1
End If
End If
Next
u = h2.Range("A" & Rows.Count).End(xlUp).Row
res = WorksheetFunction.Count(h2.Range("A2:A" & u))
HISTORIAL.Label37.Caption = HISTORIAL.Label10.Caption & " SERVICIOS ENTREGADOS: " & res
Set h1 = Sheets("history")
Set h2 = Sheets("temp")
h2.Cells.Clear
j = 2
For I = 2 To h1.Range("B" & Rows.Count).End(xlUp).Row
If h1.Cells(I, "B") = (Label10.Caption) And _
Not (h1.Cells(I, "K")) = "ENTREGADO" Then
folio = h1.Cells(I, "C")
Set b = h2.Columns("A").Find(folio, lookat:=xlWhole)
If b Is Nothing Then
h2.Cells(j, "A") = folio
j = j + 1
End If
End If
Next
u = h2.Range("A" & Rows.Count).End(xlUp).Row
res1 = WorksheetFunction.Count(h2.Range("A2:A" & u))
HISTORIAL.Label38.Caption = HISTORIAL.Label10.Caption & " SERVICIOS NO ENTREGADOS: " & res1
HISTORIAL.Label39.Caption = HISTORIAL.Label10.Caption & " TOTAL DE SERVICIOS: " & res1 + res
Si funciona, pero quisiera saber como unificarla para aprender y asi no me de problemas a futuro respecto a lentitud.