Saltar al contenido principal

¿Cómo contar / sumar celdas tachadas en Excel?

En Excel, siempre formateamos tachado para algunas celdas que indican que los valores de celda son inútiles o inválidos, para que podamos analizar los datos con mayor precisión. En este artículo, hablaré sobre cómo hacer algunos cálculos en el rango con estas celdas tachadas en Excel.

Contar celdas tachadas en Excel

Cuente sin celdas tachadas en Excel

Suma excluye las celdas tachadas en Excel


flecha azul burbuja derecha Contar celdas tachadas en Excel

Si desea saber cuántas celdas con formato tachado en un rango, puede crear una función definida por el usuario, siga los siguientes pasos:

1. Mantenga pulsado el ALT + F11 teclas para abrir el Ventana de Microsoft Visual Basic para aplicaciones.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en el Ventana de módulo.

Código de VBA: cuente las celdas tachadas

Public Function CountStrike(pWorkRng As Range) As Long
'Update 20140819
Application.Volatile
Dim pRng As Range
Dim xOut As Long
xOut = 0
For Each pRng In pWorkRng
    If pRng.Font.Strikethrough Then
        xOut = xOut + 1
    End If
Next
CountStrike = xOut
End Function

3. Luego guarde y cierre este código, vuelva a la hoja de trabajo y luego ingrese esta fórmula = CountStrike (A2: B14) a una celda en blanco, vea la captura de pantalla:

doc-count-strike-1

4. Luego presione Participar clave, y se han contado todas las celdas tachadas. Ver captura de pantalla:

doc-count-strike-1


flecha azul burbuja derecha Cuente sin celdas tachadas en Excel

Pero, a veces, es posible que desee contar solo el número de células normales que excluyen las células tachadas. El siguiente código puede ayudarte.

1. Mantenga pulsado el ALT + F11 teclas para abrir el Ventana de Microsoft Visual Basic para aplicaciones.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en el Ventana de módulo.

Código de VBA: recuento sin celdas tachadas

Public Function CountNoStrike(pWorkRng As Range) As Long
'Update 20140819
Application.Volatile
Dim pRng As Range
Dim xOut As Long
xOut = 0
For Each pRng In pWorkRng
    If Not pRng.Font.Strikethrough Then
        xOut = xOut + 1
    End If
Next
CountNoStrike = xOut
End Function

3. Luego guarde y cierre este código, vuelva a su hoja de trabajo, escriba esta fórmula = countnostrike (A2: B14) en una celda en blanco y presione Participar clave, obtendrá el resultado que necesita.

doc-count-strike-1

Note: En las fórmulas anteriores, A2: B14 es el rango al que desea aplicar las fórmulas.


flecha azul burbuja derecha Suma excluye las celdas tachadas en Excel

Debido a que las celdas tachadas no se utilizan, aquí quiero sumar solo los números normales sin los números tachados. Para resolver esta tarea, también necesita una función definida por el usuario.

1. Mantenga pulsado el ALT + F11 teclas para abrir el Ventana de Microsoft Visual Basic para aplicaciones.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en el Ventana de módulo.

Código de VBA: la suma excluye las celdas tachadas

Public Function ExcStrike(pWorkRng As Range) As Long
'Update 20140819
Application.Volatile
Dim pRng As Range
Dim xOut As Long
xOut = 0
For Each pRng In pWorkRng
    If Not pRng.Font.Strikethrough Then
        xOut = xOut + pRng.Value
    End If
Next
ExcStrike = xOut
End Function

3. Luego guarde y cierre este código, vuelva a su hoja de trabajo, escriba esta fórmula = golpe de fuerza (B2: B14) en una celda en blanco y presione Participar clave, y obtendrá la suma de todos los números sin las celdas tachadas. Ver captura de pantalla:

doc-count-strike-1

Note: En las fórmulas anteriores, B2: B14 es el rango en el que desea sumar celdas sin formato de tachado.


Artículos relacionados:

¿Cómo sumar / contar números en negrita en un rango de celdas en Excel?

¿Cómo contar y sumar celdas según el color de fondo en Excel?

¿Cómo contar / sumar celdas según los colores de fuente en Excel?

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I want to ignore the cell from count where both type of text strike and non strike available by VBA
This comment was minimized by the moderator on the site
Great! I found a little bug here. The result doesn't actualize by itself. When I do changes on the sheet, the number doesn't changes. How can I fix it? Thanks
This comment was minimized by the moderator on the site
Hi. Great code for ignoring strikethrough text whilst summing. But, is it possible to filter the data and get a subtotal which still sums without the strike through text? Thanks
This comment was minimized by the moderator on the site
This seems to round to whole numbers, and does not take into account the decimal places. For example, 1.35 + 1.00 would equal 2 instead of 2.35, but 1.50 + 1 would equal 3 instead of 2.50. How can you fix the code to add accurately?
This comment was minimized by the moderator on the site
[quote]This seems to round to whole numbers, and does not take into account the decimal places. For example, 1.35 + 1.00 would equal 2 instead of 2.35, but 1.50 + 1 would equal 3 instead of 2.50. How can you fix the code to add accurately?By Ari[/quote] ARI, just change the two words "Long" to "Double" in the formula. Here is the same formula above, with the correct Data Types to allow for values with decimal points: Public Function ExcStrike(pWorkRng As Range) As Double 'Update 20161107_IITCSglobal.com Application.Volatile Dim pRng As Range Dim xOut As Double xOut = 0 For Each pRng In pWorkRng If Not pRng.Font.Strikethrough Then xOut = xOut + pRng.Value End If Next ExcStrike = xOut End Function
This comment was minimized by the moderator on the site
Thank you very much for this information, it's extremely helpful, However, I'm having an issue using the VBA code: Sum exclude strikethrough cells.

It does not exclude the strikethrough cells in my table unless I manually perform a strikethrough then double click the cell for the code to work.

I'm using a table with a conditional format to shade and strikethrough the entire row when (Table Header called Sold) Column "W" cell contains a "Yes", then that row will have a strikethrough and grey color. The worksheet table is "InventoryItems" and is configured to calculated automatically, but the code is not being triggered to exclude the dollar amount when the cell contains the strikethrough. Could you advise what I might be doing wrong?
Thank you for your time and help.

There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations