메인 컨텐츠로 가기

Excel에서 n번째 문자 찾기 - 3가지 빠른 방법

저자: 샤오양 최종 수정 날짜: 2024-04-24

Excel의 텍스트 문자열에서 n번째로 나타나는 특정 문자를 찾는 것은 문자열을 구문 분석하거나 특정 구분 기호 또는 패턴을 기반으로 정보를 추출해야 하는 데이터 분석에 특히 유용할 수 있습니다. 예를 들어, 텍스트 문자열에서 문자 "-"가 두 번째 또는 세 번째로 나타나는 것을 찾아보겠습니다. 이 작업을 효율적으로 수행할 수 있는 간단한 기술을 보여 드리겠습니다.


수식을 사용하여 텍스트 문자열에서 n번째 문자 찾기

n번째 문자 발생을 찾는 공식을 만들 수 있습니다. 다음과 같이 하십시오:

1. 결과를 얻으려는 셀에 다음 수식을 입력하거나 복사하십시오.

=FIND(CHAR(1),SUBSTITUTE(A2,"-",CHAR(1),2))
주의 사항: 위 공식에서 :
  • A2: 문자열이 포함된 셀입니다.
  • -: 당신이 찾고 있는 캐릭터입니다.
  • 2: 찾고 싶은 두 번째 항목을 필요에 따라 2…로 변경할 수 있습니다.

2. 그런 다음 수식 채우기를 아래로 드래그하여 수식을 다른 셀에 채우고 문자의 두 번째 위치가 한 번에 표시됩니다. 스크린샷을 참조하세요.

공식 설명 :
  • 대용품 n번째 문자 발생을 인쇄할 수 없는 문자(CHAR(1))로 바꿉니다.
  • 문의 인쇄할 수 없는 문자를 검색하여 n번째 발생 위치를 제공합니다.

Excel 용 Kutools를 사용하여 텍스트 문자열에서 n 번째 문자 찾기

수식이나 VBA를 사용하는 것을 좋아하지 않는다면 편리한 대안을 고려해 볼 수 있습니다. Excel 용 Kutools. 공식 그룹 내에서 유용한 유틸리티를 찾을 수 있습니다. 문자가 문자열에서 N 번째로 나타나는 위치 찾기 셀에 있는 모든 문자의 n번째 위치를 신속하게 식별하고 반환합니다.

Excel용 Kutools를 설치한 후클릭 쿠툴 > 수식 도우미 > 수식 도우미 를 열려면 수식 도우미 대화 상자. 결과를 입력할 셀을 클릭하세요. 그런 다음 다음과 같이 하십시오.

  1. 선택 조회 의 드롭 다운 목록에서 공식 유형 섹션;
  2. 왼쪽 메뉴에서 문자가 문자열에서 N 번째로 나타나는 위치 찾기 in 공식 선택 섹션;
  3. 사용하는 문자열이 포함된 셀을 선택한 다음 지정된 문자와 n번째 항목을 텍스트 상자에 입력합니다. 인수 입력 섹션;
  4. 마지막으로 OK 버튼을 눌러 결과를 얻습니다.
방문 꿀팁: 이 기능에 관심이 있으신가요? 30일 동안 무료 평가판을 받으려면 클릭하여 다운로드.

사용자 정의 함수를 사용하여 텍스트 문자열에서 문자의 n번째 발생 찾기

이 섹션에서는 UDF를 만들고 사용하여 Excel에서 n번째 문자 발생을 찾는 방법을 살펴보고 데이터 처리를 최적화하는 데 도움이 되는 단계별 가이드를 제공합니다.

  1. 누르고있어. ALT + F11 키가 열립니다. 응용 프로그램 용 Microsoft Visual Basic 창.
  2. 끼워 넣다 > 모듈을 클릭하고 모듈 창에 다음 매크로를 붙여 넣습니다.
     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. 그런 다음 vba 창을 닫습니다. 워크시트로 돌아가서 다음 수식을 셀에 입력한 다음 채우기 핸들을 아래로 끌어 수식을 다른 셀에 채웁니다. 스크린샷을 참조하세요.
    =FindN("-",A2,3)

  4. 관련 기사:

    • 열에서 단어 발생 횟수 계산
    • 아래 스크린 샷과 같이 일부 중복 값을 포함하는 열 데이터가있는 경우 이제 수행하려는 작업은이 열에서 특정 단어의 발생 횟수를 계산하는 것입니다. 이제이 튜토리얼을 통해 Excel에서 빠르게 해결할 수있는 몇 가지 트릭을 소개합니다.
    • 문자열에서 n번째 문자 추출
    • 일반적으로 특정 문자 뒤에 문자열을 추출하고 싶을 수도 있지만, 이 경우에는 아래 스크린샷과 같이 문자열에서 n번째 문자를 추출하고 싶습니다.
    • 문자열에서 처음/마지막 n자를 추출합니다.
    • 예를 들어 각 셀에 긴 문자열이 포함 된 목록이 있고 각 문자열의 처음 3 자처럼 각 문자열에서 처음 n 개의 문자 만 추출하려고하며 이제 다음 방법을 사용하여 Excel에서 해결할 수 있습니다. .

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
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