Skip i'r prif gynnwys

Darganfyddwch yr nfed digwyddiad o gymeriad yn Excel - 3 ffordd gyflym

Awdur: Xiaoyang Wedi'i Addasu Diwethaf: 2024-04-24

Gall dod o hyd i’r nfed digwyddiad o nod penodol o fewn llinyn testun yn Excel fod yn arbennig o ddefnyddiol wrth ddadansoddi data, lle gallai fod angen i chi ddosrannu llinynnau neu echdynnu gwybodaeth yn seiliedig ar amffinyddion neu batrymau penodol. Er enghraifft, gadewch i ni ddarganfod 2il neu 3ydd digwyddiad y nod "-" mewn llinyn testun. Byddaf yn dangos technegau syml i gyflawni'r dasg hon yn effeithlon.


Darganfyddwch nfed digwyddiad nod mewn llinyn testun gyda fformiwla

Gallwch chi lunio fformiwla i ddod o hyd i'r nfed digwyddiad o gymeriad. Gwnewch fel hyn os gwelwch yn dda:

1. Rhowch neu gopïwch y fformiwla ganlynol i mewn i gell lle rydych chi am gael y canlyniad:

=FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),2))
Nodyn: Yn y fformiwla uchod:
  • A2: Y gell sy'n cynnwys y llinyn.
  • -: Y cymeriad rydych chi'n chwilio amdano.
  • 2: Yr 2il ddigwyddiad rydych chi am ei ddarganfod, gallwch chi ei newid i 3,4 ... yn ôl yr angen.

2. Yna, llusgwch y llenwi fformiwla i lenwi'r fformiwla i gelloedd eraill, ac 2il safle'r nod - yn cael eu harddangos ar unwaith, gweler y sgrinlun:

Esboniad o'r fformiwla:
  • TANYSGRIFIAD yn disodli nfed digwyddiad y nod gyda nod na ellir ei argraffu (CHAR(1)).
  • DERBYN yn chwilio am y nod anargraffadwy hwn, gan roi safle'r nfed digwyddiad.

Darganfyddwch nfed digwyddiad o gymeriad mewn llinyn testun gyda Kutools ar gyfer Excel

Os nad ydych chi'n ffan o ddefnyddio fformiwla neu VBA, efallai y byddwch chi'n ystyried dewis arall cyfleus - Kutools ar gyfer Excel. O fewn ei grwpiau Fformiwla, fe welwch gyfleustodau defnyddiol - Darganfyddwch ble mae'r cymeriad yn ymddangos Nth mewn llinyn sy'n nodi ac yn dychwelyd nfed safle unrhyw gymeriad mewn cell yn gyflym.

Ar ôl gosod Kutools ar gyfer Excel, Cliciwch Kutools > Cynorthwyydd Fformiwla > Cynorthwyydd Fformiwla i agor y Cynorthwyydd Fformiwla blwch deialog. Cliciwch ar gell lle rydych chi am roi'r canlyniad. Yna, gwnewch fel a ganlyn:

  1. dewiswch Am-edrych o'r rhestr ddisgynnol o Math o Fformiwla adran;
  2. Dewiswch Darganfyddwch ble mae'r cymeriad yn ymddangos Nth mewn llinyn in Dewiswch fformiwla adran;
  3. Dewiswch y gell sy'n cynnwys y llinyn a ddefnyddiwch, yna teipiwch y nod penodedig a'r nfed digwyddiad i'r blychau testun yn y Mewnbwn dadleuon adran;
  4. O'r diwedd, cliciwch OK botwm i gael y canlyniad.
Awgrymiadau: Diddordeb yn y nodwedd hon, os gwelwch yn dda cliciwch i'w lawrlwytho i gael treial am ddim am 30 diwrnod.

Darganfyddwch yr nfed digwyddiad o nod mewn llinyn testun gyda Swyddogaeth Diffiniedig Defnyddiwr

Yn yr adran hon, byddwn yn archwilio sut i greu a defnyddio UDF i ddod o hyd i'r nfed digwyddiad o gymeriad yn Excel, gan ddarparu canllaw cam wrth gam i'ch helpu i optimeiddio eich trin data.

  1. Dal i lawr y ALT + F11 allweddi, ac mae'n agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.
  2. Cliciwch Mewnosod > Modiwlau, a gludwch y macro canlynol yn y Ffenestr Modiwl.
     Function FindN(sFindWhat As String, _
    sInputString As String, N As Integer) As Integer
    'Updateby Extendoffice
    Dim J As Integer
    Application.Volatile
    FindN = 0
    For J = 1 To N
    FindN = InStr(FindN + 1, sInputString, sFindWhat)
    If FindN = 0 Then Exit For
    Next
    End Function
  3. Yna, caewch y ffenestr vba. Ewch yn ôl i'r daflen waith, rhowch y fformiwla ganlynol i mewn i gell, ac yna llusgwch y ddolen llenwi i lawr i lenwi'r fformiwla i gelloedd eraill, gweler y sgrinlun:
    =FindN("-",A2,3)

  4. Erthyglau cysylltiedig:

    • Cyfrwch nifer y digwyddiadau o air mewn colofn
    • Os oes gennych ddata colofn sy'n cynnwys rhai gwerthoedd dyblyg fel y dangosir isod, a nawr yr hyn yr ydych am ei wneud yw cyfrif nifer yr achosion o air penodol yn y golofn hon. Nawr gyda'r tiwtorial hwn, rwy'n cyflwyno rhai triciau i'w ddatrys yn gyflym yn Excel.
    • Echdynnu nfed nod o linyn
    • Yn gyffredinol, efallai y byddwch am dynnu llinyn ar ôl cymeriad penodol, ond yn yr achos hwn, rwyf am dynnu'r nfed cymeriad o linyn fel y dangosir y sgrin isod.
    • Tynnu'r n nod cyntaf/olaf o'r llinyn
    • Er enghraifft, mae rhestr gyda llinynnau hir ym mhob cell, ac rydych chi am echdynnu'r n nodau cyntaf o bob llinyn yn unig, fel 3 nod cyntaf pob llinyn, a nawr gallwch chi ddefnyddio'r dulliau canlynol i'w datrys yn Excel .

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Your formula to find the Nth occurrence of a character in a string does not work. Using your example, adding 2 to the results of the imbedded find ensures a starting position for the initial find of a position beyond the 1st two c's but changing the +2 to +3 does not yield the position of the 4th "c", it simply starts the search one character deeper into the string and the result is still the 3rd "c". To find the 4th "c" the search must begin beyond the position of the 3rd "c". I look forward to your new solution.
This comment was minimized by the moderator on the site
Hello, David

Yes, as you said, the first formula does not work correctly, you can apply the second formula:
=FIND(CHAR(1),SUBSTITUTE(A2,"c",CHAR(1),2))

Note: The number "2" in the formula means the second "c", if you want to get the third, fourth "c", just change the number 2 to 3,4 as you need.
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Find formula1 is imperfect. It will be a great help if it is removed. I have lost lot of time trying for 4th occurance of "a" in "vedanarayanan" Thanks.
This comment was minimized by the moderator on the site
To handle the exception of the formula, you can use same with if and iserro
=IF(ISERR(FIND("c",A1,FIND("c",A1)+2)),FIND("c",A1,FIND("c",A1)+0),FIND("c",A1,FIND("c",A1)+2))
This comment was minimized by the moderator on the site
"Substitute" lets you find the Nth occurrence of a term, so combine it with "find" as follows (where 5=5th occurrence):

=FIND(CHAR(1),SUBSTITUTE(A1,"c",CHAR(1),5))
This comment was minimized by the moderator on the site
Excellent! I am glad I scrolled up to review other comments after posting my own.
This comment was minimized by the moderator on the site
This is the correct answer! please replace this whole article with this one line of code.....
This comment was minimized by the moderator on the site
The first formula is completely useless and wrong but it works just correct for this example as the first and second "c"s are adjacent. The correct formula is:


For 2nd occurence -
=FIND("c",A1,FIND("c",A1)+1)

For 3rd occurence -
=FIND("c",A1,FIND("c",A1,FIND("c",A1)+1)+1) and so on...
This comment was minimized by the moderator on the site
Absolutely agree. The +2, or +3 etc.....entirely depends on the spacing between the n and (n+1) occurences of "c". Thus you would have to manually adjust for every cell if you were trying to copy this formula down a column for instance. Essentially the same as manually counting.


Ex. Let's try to find the 4th occurrence of "c" in cell A1 using the provided formula. Per the article we should use +3 in our nested FIND function to find the 4th occurrence.


Text in Cell A1:

"cab car abc cole cube"

Manually counting, the 4th occurrence is the "c" in cole in the character position of 13.


=FIND("c",A1,FIND("c",A1)+3)

The nested function, FIND("c",A1) will find the first occurrence of "c" in position 1.

Therefore,

FIND("c",A1)+3 = 1+3 = 4

Plugging that back into our formula,

=FIND("c",A1,FIND("c",A1)+3) = FIND("c",A1,1+3) = FIND("c",A1,4)

This new formula will look for the first occurrence of "c" beginning from character position 4. The 4th character in the string is the space just after cab.

Therefore, the formula will find the "c" in car and return the value of 5 for our formula. As we know from manually counting we are looking for 13 as the output.
This comment was minimized by the moderator on the site
The firs formula works correct in my version, in the note, it has explained how to find the third or forth or nth "c".

Note: You can change the 2 in the formula based on your needs. For example, if you want to find the fourth position of "c", you can change the 2 to 3. And if you want to find the first position of "c", you shuold change 2 to 0.
This comment was minimized by the moderator on the site
Try to find out the position of the second c with the first sentence of my above comment as the string using the first formula. You'll get to know how correct it is!
This comment was minimized by the moderator on the site
Hello all,

I have a text in an Excel cell " BY TRANSFER-NEFT*HDFC0000001*N08745987123546*J0032331*KUMAR--"

I need a function to extract just "N08745987123546"

Thanks
This comment was minimized by the moderator on the site
Hello, do you want to extract the numbers after No and the number of numbers are fixed? If so, you can use Kutools for Exccel's Extract text function, type No????to extract.
This comment was minimized by the moderator on the site
HI ALL,
I have a text in an Excel cell " BY TRANSFER-NEFT*HDHC0065431*N053112345624801*K0038331*krishna--"
I need a function to extract just "N053112345624801"
This comment was minimized by the moderator on the site
Formula 1 doesn't work on fourth, fifth, sixth etc. so (+3,4,5) will always show third position of letter "c" which is 19 second formula is working though.
This comment was minimized by the moderator on the site
Hello all, I have a text in an Excel cell "23 floyd lane, longville,KN 14564" I need a function to extract just "longville" Thanks
This comment was minimized by the moderator on the site
If you must use a function, try: =TRIM(MID(A1,SEARCH(",",A1)+1,SEARCH("!@#",SUBSTITUTE(A1,",","!@#",2))-SEARCH(",",A1)-1)) Otherwise, you might consider Data > Text to Columns > Delimited (using a comma as the separator).
This comment was minimized by the moderator on the site
Try this: =INDEX(SMALL(IF(MID(A1,MATCH(ROW(INDIRECT(1&":"&LEN(A1))),ROW(INDIRECT(1&":"&LEN(A1))),0),1)="c",MATCH(ROW(INDIRECT(1&":"&LEN(A1))),ROW(INDIRECT(1&":"&LEN(A1))),0),""),MATCH(ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c","")))),ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c","")))),0)),2) where "c" is the character required and 2 is the position. Note this is an array formula.
This comment was minimized by the moderator on the site
this is simpler: =INDEX(SMALL(IF(MID(A1,ROW(INDIRECT(1&":"&LEN(A1))),1)="c",ROW(INDIRECT(1&":"&LEN(A1))),""),ROW(INDIRECT(1&":"&LEN(A1)-LEN(SUBSTITUTE(A1,"c",""))))),2)
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations