Macro Contar valores y resultado visualizarlo en TextBox

Tengo 03 TextBox y necesito que se actualice cada vez que ingrese datos (Adjunto código fuente utilizado, el cual funciona bien y solo falta complementar los contadores en los TextBox). Explico:

TextBox2; debe de contar valores únicos de la columna "A", hoja "Report". Considerar que es una base de datos filtrada según una condición de la columna "AD" hoja "Report".

TextBox7; debe de contar las celdas llenas de la columna "B" considerando solo valores únicos de la columna "A" hoja "Report".

TextBox11; debe de mostrar la resta del TextBox2 - TextBox7

Agradezco de antemano por las enseñanzas.

Private Sub CommandButton5_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
'Ingresar datos
    pedido = TextBox9.value
    If pedido = "" Then
        MsgBox "Debes capturar un número de pedido"
        TextBox9.SetFocus
        Exit Sub
    End If
    If IsNumeric(pedido) Then pedido = Val(pedido)
    Set h = Sheets("Report")
    Set r = h.Columns("A")
    Set b = r.Find(pedido, LookAt:=xlWhole)
        If Not b Is Nothing Then
        Celda = b.Address
        Do
            'detalle
            If h.Cells(b.Row, "B") = "" Then
                h.Cells(b.Row, "B") = ComboBox2.value 'Columna B Courier
                h.Cells(b.Row, "C") = ComboBox3.value 'Columna C Placa
                h.Cells(b.Row, "D") = TextBox8.value 'Columna D Nombre del Transportista
                h.Cells(b.Row, "E") = TextBox9.value 'Columna E N° de Pedido
                h.Cells(b.Row, "F") = TextBox10.value 'Columna F GR Hija
                h.Cells(b.Row, "J") = Now            'Columna J Fecha y hora
                h.Cells(b.Row, "K") = Application.UserName 'Columna K Usuario
                TextBox7 = Sheets("Datos").Range("E2")
                TextBox2 = Sheets("Datos").Range("F2")
                TextBox11 = Sheets("Datos").Range("G2")
            Else
                MsgBox "Pedido ya existe"
                TextBox9.value = ""
        TextBox9.value = ""
        TextBox10.value = ""
        TextBox9.SetFocus
                Exit Sub
            End If
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> Celda
        TextBox9.value = ""
        TextBox9.value = ""
        TextBox10.value = ""
        TextBox9.SetFocus
    Else
        MsgBox "El pedido no existe"
        TextBox9.value = ""
        TextBox9.value = ""
        TextBox10.value = ""
        TextBox9.SetFocus
    End If
  With TextBox7
    .Font.Size = 10
    .TextAlign = fmTextAlignCenter
    .AutoSize = True
End With
With TextBox2
    .Font.Size = 10
    .TextAlign = fmTextAlignCenter
    .AutoSize = True
End With
With TextBox11
    .Font.Size = 10
    .TextAlign = fmTextAlignCenter
    .AutoSize = True
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Application.CutCopyMode = False
End Sub

Añade tu respuesta

Haz clic para o