Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

contar registros visibles

publicado

buenas como estan, quisiera saber si alguien me puede ayudar a modificar esta macro que cuenta los registros únicos totales , pero lo que necesito ahora que solo cuente los registros únicos visibles ya que tengo que usar filtros.

Desde ya muchas gracias

 
Function contar_unicos(rngSeleccion As Range)
 
    Dim collUnicos As New Collection
    Dim rngCell As Range
 
 
    On Error Resume Next
    For Each rngCell In rngSeleccion
        collUnicos.Add rngCell, CStr(rngCell)
    Next rngCell
    On Error GoTo 0
 
    contar_unicos = collUnicos.Count
 
End Function

Featured Replies

publicado

Hola, puedes hacerle esta modificación:

Function contar_unicos(rngSeleccion As Range)

    Dim collUnicos As New Collection
    Dim rngCell As Range


    On Error Resume Next
    For Each rngCell In rngSeleccion.SpecialCells(xlCellTypeVisible)
        collUnicos.Add rngCell, CStr(rngCell)
    Next rngCell
    On Error GoTo 0

    contar_unicos = collUnicos.Count

End Function

 

publicado

hola, a ambos !

o puedes usar esta variante:

Function cuentaUnicosEnRangoFiltrado(rango As Range) As Long
' el nombre de la funcion es obvio ' _
  pasar como argumento el rango filtrado SIN el tiitulo ' _
  R&D: Héctor Miguel Orozco Díaz ' _
  una de las contadas situaciones en que el metodo Evaluate se puede usar en una UDF llamada desde celdas '
  Dim a As String, b As String
  a = rango(1).Address(0, 0): b = rango.Address(0, 0)
  cuentaUnicosEnRangoFiltrado = Evaluate( _
    "sum(if(frequency(if(subtotal(3,offset(" & a & ",row(" & b & ")-row(" & _
    a & "),)),match(" & b & "," & b & ",)),row(" & b & ")-row(" & a & ")+1),1))")
End Function

 

  • 2 weeks later...
publicado
  • Autor

Hola como les va, desde ya gracias por su ayuda..

Me parece que estoy haciendo algo mal porque la sugerencia de Diego no me funciono, y la la sugerencia de Héctor no se como aplicarla ya que no entiendo mucho de macros.

Dejo un ejemplo de la macros para ver si me dicen que estoy haciendo mal.

Nuevamente muchas gracias

Saludos

contar-unicos (1).xlsm

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.