Contar el numero de datos que salen al filtrar una hoja

Tengo un código el cual me ayuda a filtrar una información

El cual me funciona muy bien

Pero quisiera agregarle que me cuente el numero de datos que ha filtrado me lo coloque en un msgbox

Private Sub CommandButton1_Click()
If ComboBox1.Value = Empty Then
MsgBox "No haz colocado ningun dato", vbCritical, "ERROr! - MES"
Exit Sub
End If
     Sheets(Hoja1.Name).Activate
    Sheets(Hoja1.Name).Range("B3:L3").Select
    Selection.AutoFilter
    ActiveSheet.Range("$B$3:$L$19").AutoFilter field:=9, Criteria1:=ComboBox1.Value
    u = Range("J" & Rows.Count).End(xlUp).Row
    MsgBox Range("B:B").Count - Range("B:B").SpecialCells(xlCellTypeBlanks).Count
    If u = 3 Then
        MsgBox "No hay datos para imprimir el mes de: " & ComboBox1.Value, vbInformation, "INFORMATIVO"
        ComboBox1.Value = Empty
        Selection.AutoFilter
    End If
End Sub

1 Respuesta

Respuesta
1

Te anexo el código

Private Sub CommandButton1_Click()
    If ComboBox1.Value = Empty Then
    MsgBox "No haz colocado ningun dato", vbCritical, "ERROr! - MES"
    Exit Sub
    End If
    Sheets(Hoja1.Name).Activate
    Sheets(Hoja1.Name).Range("B3:L3").Select
    Selection.AutoFilter
    ActiveSheet.Range("$B$3:$L$19").AutoFilter field:=9, Criteria1:=ComboBox1.Value
    u = Range("J" & Rows.Count).End(xlUp).Row
    'MsgBox Range("B:B").Count - Range("B:B").SpecialCells(xlCellTypeBlanks).Count
    If u = 3 Then
        MsgBox "No hay datos para imprimir el mes de: " & ComboBox1.Value, vbInformation, "INFORMATIVO"
        ComboBox1.Value = Empty
        Selection.AutoFilter
    Else
        cuantos = Range("B4:B" & u).SpecialCells(xlCellTypeVisible).Count
        MsgBox "Datos filtrados : " & cuantos
    End If
End Sub

sal u dos

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas