Ga naar hoofdinhoud

Tel door komma's gescheiden waarden in een cel

In deze tutorial leer je hoe je een combinatie van de LEN-, TRIM- en SUBSTITUTE-functies gebruikt om door komma's gescheiden waarden in een cel in Excel te tellen.


Hoe door komma's gescheiden waarden in een cel in Excel te tellen?

Zoals de onderstaande schermafbeelding laat zien, is er een door komma's gescheiden stringlijst in kolom B waarvan u de door komma's gescheiden waarden in elke cel wilt tellen, doe dit als volgt om dit te bereiken.

Generieke formule

=IF(ISBLANK(B3),"",LEN(TRIM(B3))-LEN(SUBSTITUTE(TRIM(B3),",",""))+1)

argumenten

A1: Vertegenwoordigt de cel met de door komma's gescheiden tekenreeks waarvan u de door komma's gescheiden waarden zult tellen.

Hoe gebruik je deze formule?

1. Selecteer een lege cel om het resultaat uit te voeren. In dit geval selecteer ik cel D3.

2. Voer de onderstaande formule in en druk op Enter sleutel. En sleep vervolgens de vulhendel helemaal naar beneden om deze op andere cellen toe te passen.

=IF(ISBLANK(B3),"",LEN(TRIM(B3))-LEN(SUBSTITUTE(TRIM(B3),",",""))+1)

Note: In deze formule is B3 de cel met de door komma's gescheiden tekenreeks waarin u door komma's gescheiden waarden telt. U kunt het naar behoefte wijzigen.

Hoe werkt deze formule?

=IF(ISBLANK(B3),"",LEN(TRIM(B3))-LEN(SUBSTITUTE(TRIM(B3),",",""))+1)

1. LEN(TRIM(B3)): De TRIM-functie verwijdert alle extractiespaties uit de door komma's gescheiden tekenreeks "AA, BB, CC, DD", en houdt alleen een enkele spatie tussen woorden. En dan berekent de LEN-functie de totale lengte van "AA, BB, CC, DD" en retourneert het resultaat als 14;

2. LEN(SUBSTITUTE(TRIM(B3),",",""))

  • SUBSTITUTE(TRIM(B3),",",""): Zoals de bovenstaande uitleg laat zien, verwijdert de TRIM-functie hier alle extractieruimte van "AA, BB, CC, DD" en retourneert het resultaat als "AA, BB, CC, DD". En dan vervangt de functie VERVANGEN alle komma's in "AA, BB, CC, DD" door niets en krijg je het resultaat "AA BB CC DD";
  • LEN("AA BB CC DD"): De functie LEN retourneert het aantal tekens in een tekstreeks "AA BB CC DD". Het resultaat is 11.

3. 14-11 1 +: Gebruik hier de totale lengte van "AA, BB, CC, DD" en trek de totale lengte van "AA BB CC DD" af om het totale aantal komma's in de string te krijgen (14-11 = 3). Omdat er altijd een woord na de laatste komma staat, moet u 1 bij nummer 3 optellen om het totale aantal door komma's gescheiden woorden in de string te krijgen. Hier is het resultaat 4.

4. ALS(ISLEEG(B3),"",14): De If-functie zegt hier dat als B3 leeg is, dan niets retourneert, anders het getal 14 retourneert. Hier bevat B3 waarden, dus de ALS-functie retourneert het getal 14.


Gerelateerde functies

Excel LEN-functie
De Excel LEN-functie retourneert het aantal tekens in een tekstreeks.

Excel SUBSTITUTE-functie
De Excel SUBSTITUTE-functie vervangt tekst of tekens binnen een tekstreeks door een andere tekst of tekens.

Excel TRIM-functie
De Excel TRIM-functie verwijdert alle extra spaties uit de tekstreeks en houdt alleen enkele spaties tussen woorden.


Gerelateerde formules

Tel het aantal exemplaren van specifieke tekens in een Excel-cel
In deze tutorial wordt uitgelegd hoe u formules toepast op basis van de LEN- en SUSTITUTE-functies om het aantal keren te tellen dat een specifiek teken in een Excel-cel voorkomt.

Tel specifieke tekens in een reeks cellen
Deze tutorial introduceert enkele formules om het aantal keren te tellen dat een specifiek teken in een bereik in Excel voorkomt.

Tel specifieke woorden in een cel in Excel
Dit artikel gaat een formule introduceren om het aantal keren te tellen dat een specifiek woord in een cel in Excel voorkomt.

Tel specifieke woorden in een bereik in Excel
In dit artikel wordt een formule uitgelegd om het aantal keren te tellen dat een specifiek woord in een celbereik in Excel voorkomt.

Tel het aantal tekens in een cel in Excel
Het totale aantal tekens omvat niet alleen alle letters, maar ook alle spaties, leestekens en symbolen in de cel. Volg deze tutorial om eenvoudig het totale aantal tekens in een cel te tellen met de LEN-functie in Excel.

Tel het aantal tekens in een bereik in Excel
In dit artikel wordt een formule uitgelegd om het totale aantal tekens te tellen dat in een celbereik in Excel voorkomt.


De beste tools voor kantoorproductiviteit

Kutools for Excel - Helpt u zich te onderscheiden van de menigte

🤖 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten  |  Verwijder lege rijen  |  Combineer kolommen of cellen zonder gegevens te verliezen  |  Ronde zonder formule ...
Super VLookup: Meerdere criteria  |  Meerdere waarde  |  Over meerdere vellen  |  Fuzzy opzoeken...
Gev. Keuzelijst: Gemakkelijke vervolgkeuzelijst  |  Afhankelijke vervolgkeuzelijst  |  Multi-select vervolgkeuzelijst...
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  Vergelijk Kolommen met Selecteer dezelfde en verschillende cellen ...
Uitgelichte functies: Raster focus  |  Ontwerpweergave  |  Grote formulebalk  |  Werkmap- en bladbeheer | resource Library (Auto-tekst)  |  Datumkiezer  |  Combineer werkbladen  |  Cellen coderen/decoderen  |  Stuur e-mails per lijst  |  Super filter  |  Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen ...)  |  50+ tabel Types (Gantt Chart ...)  |  40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag ...)  |  19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad ...)  |  12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion ...)  |  7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Excel-cellen splitsen ...)  |  ... en meer

Kutools voor Excel beschikt over meer dan 300 functies, Ervoor zorgen dat wat u nodig heeft slechts één klik verwijderd is...

Omschrijving


Office-tabblad - Schakel lezen en bewerken met tabbladen in Microsoft Office in (inclusief Excel)

  • Een seconde om te schakelen tussen tientallen geopende documenten!
  • Verminder elke dag honderden muisklikken voor u, zeg maar dag tegen muishand.
  • Verhoogt uw productiviteit met 50% bij het bekijken en bewerken van meerdere documenten.
  • Brengt efficiënte tabbladen naar Office (inclusief Excel), net als Chrome, Edge en Firefox.
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks for this formula. I had been trying a different formula: =LEN(A1)-LEN(SUBSTITUTE(A1),",",""))+1 but if the cell was blank it would have a 1 in it. This doesn't, so it works for counting up numbers. In my case, I'm trying to count the number of dates such as Oct. 6, 13, 20, 27. However, it's not working when it comes to multiplying the count by the cost of the lesson. For instance, if John had lessons on Oct. 6, 13, 20, 27, I have a column for dates of lessons, then a column for number of lessons, a column for the cost of each lesson (30 or 45), and a column to calculate monthly tuition due (number of lessons x cost). For the student with blank dates/no lessons, it gives an error value, and therefore affects my total tuition for the month. Please advise. Thanks!
This comment was minimized by the moderator on the site
Hi sir, formula is not working properly. I have numerical data in cells. It works correctly in cells where numbers consists upon two digits like 22,43,59 etc, but it fails when there comes data like 103,144 or 165,45 etc. Please help
This comment was minimized by the moderator on the site
Hi,
The formula works fine for me and do not reproduce the error you mentioned. May I ask what version of Excel you are using?
This comment was minimized by the moderator on the site
Office 2021
This comment was minimized by the moderator on the site
thanks! this worked very well, except for that it also returns "1" when the cell is blank. I'm trying to count the number of concatenated dates. There are some cells that don't have any dates, and those are coming back with the number '1'. However, the formula is still counting correctly the number of dates otherwise.
This comment was minimized by the moderator on the site
Hi Alicia Majcher,
Thank you for your feedback. If you want to return nothing when the reference cell is blank, apply the following formula.
=IF(ISBLANK(A30),"",LEN(TRIM(A30))-LEN(SUBSTITUTE(TRIM(A30),",",""))+1)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations