Skip to main content

Faigh an nú tarlú de charachtair in Excel - 3 bhealach tapa

Is féidir an nú tarlú de charachtair ar leith laistigh de theaghrán téacs in Excel a bheith an-úsáideach in anailís sonraí, áit a bhféadfadh go mbeadh ort teaghráin a pharsáil nó faisnéis a bhaint bunaithe ar theorainneacha nó patrúin áirithe. Mar shampla, faighimis an 2ú nó 3ú tarlúint an charachtair "-" i teaghrán téacs. Léireoidh mé teicnící simplí chun an tasc seo a chur i gcrích go héifeachtach.


Faigh an nú tarlú de charachtair i teaghrán téacs le foirmle

Is féidir leat foirmle a dhéanamh chun an nú tarlú de charachtair a fháil. Déan mar seo le do thoil:

1. Cuir isteach nó cóipeáil an fhoirmle seo a leanas isteach i gcill inar mian leat an toradh a fháil:

=FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),2))
nótaí: San fhoirmle thuas:
  • A2: An chill ina bhfuil an sreangán.
  • -: An carachtar atá á lorg agat.
  • 2: An 2ú tarlú is mian leat a fháil, is féidir leat é a athrú go 3,4 ... mar is gá duit.

2. Ansin, tarraing an fhoirmle a líonadh síos chun an fhoirmle a líonadh go cealla eile, agus 2ú suíomh an charachtair - ar taispeáint ag an am céanna, féach an scáileán:

Míniú ar an bhfoirmle:
  • SUBSTAITIÚIL cuirtear carachtar neamhphriontáilte (CHAR(1)) in ionad an nú tarlú den charachtar.
  • AIMSIGH cuardach a dhéanamh ar an gcarachtar neamhphriontáilte seo, ag tabhairt suíomh an nú tarlúint.

Faigh nth tarlú de charachtar i teaghrán téacs le Kutools le haghaidh Excel

Mura bhfuil fonn ort foirmle nó VBA a úsáid, b’fhéidir go gceapfá rogha eile áisiúil - Kutools le haghaidh Excel. Laistigh dá ngrúpaí Foirmle, gheobhaidh tú áirgiúlacht úsáideach - Faigh cá bhfuil an carachtar Nth i dtéad a shainaithníonn agus a sheolann ar ais go tapa an nú suíomh aon charachtair i gcill.

Tar éis Kutools le haghaidh Excel a shuiteáil, Cliceáil Kutools > Cúntóir Foirmle > Cúntóir Foirmle a oscailt Cúntóir Foirmle bosca dialóige. Cliceáil cill ar mhaith leat an toradh a chur. Ansin, déan mar a leanas:

  1. Roghnaigh Féach suas ó liosta anuas Cineál Foirmle alt;
  2. Roghnaigh Faigh cá bhfuil an carachtar Nth i dtéad in Roghnaigh foirmle alt;
  3. Roghnaigh an chill ina bhfuil an teaghrán a úsáideann tú, ansin clóscríobh an carachtar sonraithe agus an nú tarlú sna boscaí téacs sa bhosca Ionchur argóintí alt;
  4. Faoi dheireadh, cliceáil OK cnaipe chun an toradh a fháil.

Faigh an nú tarlú de charachtair i teaghrán téacs le Feidhm Shainithe Úsáideora

Sa chuid seo, déanfaimid iniúchadh ar conas UDF a chruthú agus a úsáid chun an nú tarlú de charachtair a fháil in Excel, ag soláthar treoir céim ar chéim chun cabhrú leat do láimhseáil sonraí a bharrfheabhsú.

  1. Coinnigh síos an ALT + F11 eochracha, agus osclaíonn sé an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.
  2. cliceáil Ionsáigh > Modúil, agus greamaigh an macra seo a leanas i bhFuinneog an Mhodúil.
     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. Ansin, dún an fhuinneog vba. Téigh ar ais go dtí an bhileog oibre, cuir an fhoirmle seo a leanas isteach i gcill, agus ansin tarraing an láimhseáil líonta síos chun an fhoirmle a líonadh chuig cealla eile, féach screenshot:
    =FindN("-",A2,3)

  4. Airteagail ghaolmhara:

    • Comhair líon na dtarlaíonn focal i gcolún
    • Má tá sonraí colúin agat a chuimsíonn roinnt luachanna dúblacha mar atá thíos an pictiúr a thaispeántar, agus anois is mian leat a dhéanamh líon na dtarlaíonn focal ar leith sa cholún seo a chomhaireamh. Anois leis an rang teagaisc seo, tugaim isteach roinnt cleasanna chun é a réiteach go tapa in Excel.
    • Sliocht an nú carachtar as teaghrán
    • Go ginearálta, b'fhéidir gur mhaith leat teaghrán a bhaint as carachtar ar leith, ach sa chás seo, ba mhaith liom an nú carachtar a bhaint as teaghrán mar a thaispeántar an scáileán thíos.
    • Bain an chéad nó an n carachtar deiridh as teaghrán
    • Mar shampla, tá liosta ann le teaghráin fhada i ngach cill, agus ba mhaith leat na chéad n carachtair a bhaint as gach sreang amháin, cosúil leis na chéad 3 charachtar de gach sreang, agus anois is féidir leat na modhanna seo a leanas a úsáid chun é a réiteach in Excel .

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
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