Preskoči na glavno vsebino

Kako šteti / seštevati prečrtane celice v Excelu?

V Excelu vedno prečrtamo nekatere celice, ki označujejo, da so vrednosti celic neuporabne ali neveljavne, tako da lahko podatke natančneje analiziramo. V tem članku bom govoril o tem, kako narediti nekaj izračunov v obsegu s temi prečrtanimi celicami v Excelu.

Štejte prečrtane celice v Excelu

Štejte brez prečrtanih celic v Excelu

Vsota v Excelu izključuje prečrtane celice


puščica modri desni mehurček Štejte prečrtane celice v Excelu

Če želite vedeti, koliko celic s prečrtano obliko v obsegu lahko ustvarite uporabniško določeno funkcijo, naredite naslednje:

1. Držite tipko ALT + F11 tipke za odpiranje Okno Microsoft Visual Basic for Applications.

2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Okno modula.

Koda VBA: preštejte prečrtane celice

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. Nato shranite in zaprite to kodo ter se vrnite na delovni list in nato vnesite to formulo = CountStrike (A2: B14) v prazno celico si oglejte posnetek zaslona:

doc-count-strike-1

4. Nato pritisnite Vnesite in preštete so bile vse prečrtane celice. Oglejte si posnetek zaslona:

doc-count-strike-1


puščica modri desni mehurček Štejte brez prečrtanih celic v Excelu

Včasih boste morda želeli prešteti število običajnih celic, ki ne vključujejo prečrtanih celic. Naslednja koda vam lahko pomaga.

1. Držite tipko ALT + F11 tipke za odpiranje Okno Microsoft Visual Basic for Applications.

2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Okno modula.

Koda VBA: Štetje brez prečrtanih celic

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. Nato shranite in zaprite to kodo, se vrnite na svoj delovni list in vnesite to formulo = countnostrike (A2: B14) v prazno celico in pritisnite Vnesite tipka, potem boste dobili rezultat, ki ga potrebujete.

doc-count-strike-1

Opombe: V zgornjih formulah, A2: B14 je obseg, za katerega želite uporabiti formule.


puščica modri desni mehurček Vsota v Excelu izključuje prečrtane celice

Ker prečrtane celice niso uporabljene, želim tukaj povzeti samo običajna števila brez prečrtanih številk. Za rešitev te naloge potrebujete tudi uporabniško določeno funkcijo.

1. Držite tipko ALT + F11 tipke za odpiranje Okno Microsoft Visual Basic for Applications.

2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Okno modula.

Koda VBA: Vsota izključuje prečrtane celice

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. Nato shranite in zaprite to kodo, se vrnite na svoj delovni list in vnesite to formulo = hitri udarec (B2: B14) v prazno celico in pritisnite Vnesite tipko in dobili boste seštevek vseh števil brez prečrtanih celic. Oglejte si posnetek zaslona:

doc-count-strike-1

Opombe: V zgornjih formulah, B2: B14 je obseg, v katerem želite seštevati celice brez prečrtane oblike.


Sorodni članki:

Kako seštevati / šteti krepke številke v obsegu celic v Excelu?

Kako šteti in seštevati celice glede na barvo ozadja v Excelu?

Kako šteti / seštevati celice na podlagi barv pisave v Excelu?

Najboljša pisarniška orodja za produktivnost

🤖 Kutools AI Aide: Revolucionirajte analizo podatkov na podlagi: Inteligentna izvedba   |  Ustvari kodo  |  Ustvarite formule po meri  |  Analizirajte podatke in ustvarite grafikone  |  Prikličite funkcije Kutools...
Priljubljene funkcije: Poiščite, označite ali identificirajte dvojnike   |  Izbriši prazne vrstice   |  Združite stolpce ali celice brez izgube podatkov   |   Krog brez formule ...
Super iskanje: Več kriterijev VLookup    Multiple Value VLookup  |   VLookup na več listih   |   Nejasno iskanje ....
Napredni spustni seznam: Hitro ustvarite spustni seznam   |  Odvisni spustni seznam   |  Večkrat izberite spustni seznam ....
Upravitelj stolpcev: Dodajte določeno število stolpcev  |  Premakni stolpce  |  Preklop stanja vidnosti skritih stolpcev  |  Primerjaj obsege in stolpce ...
Predstavljene funkcije: Mrežni fokus   |  Pogled oblikovanja   |   Velika vrstica formule    Upravitelj delovnih zvezkov in listov   |  Knjižnica virov (Samodejno besedilo)   |  Izbirnik datuma   |  Združite delovne liste   |  Šifriranje/dešifriranje celic    Pošljite e-pošto po seznamu   |  Super filter   |   Poseben filter (filter krepko/ležeče/prečrtano ...) ...
15 najboljših kompletov orodij12 Besedilo Orodja (dodajanje besedila, Odstrani znake,...)   |   50 + Graf Vrste (Gantt Chart,...)   |   40+ Praktično Formule (Izračunajte starost glede na rojstni dan,...)   |   19 vstavljanje Orodja (Vstavite kodo QR, Vstavi sliko s poti,...)   |   12 Pretvorba Orodja (Številke v besede, Pretvorba valut,...)   |   7 Spoji in razdeli Orodja (Napredne kombinirane vrstice, Razdeljene celice,...)   |   ... in več

Napolnite svoje Excelove spretnosti s Kutools za Excel in izkusite učinkovitost kot še nikoli prej. Kutools za Excel ponuja več kot 300 naprednih funkcij za povečanje produktivnosti in prihranek časa.  Kliknite tukaj, če želite pridobiti funkcijo, ki jo najbolj potrebujete...

Opis


Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50%in vsak dan zmanjša na stotine klikov miške za vas!
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