메인 컨텐츠로 가기

Excel의 기준에 따라 텍스트를 쉽게 연결하는 방법은 무엇입니까?

중복 된 ID 번호 열과 이름 열이있는 경우 왼쪽 스크린 샷에 표시된 고유 ID 번호를 기반으로 이름을 연결하여 기준에 따라 텍스트를 빠르게 결합하려면 어떻게해야합니까? Excel에서합니까?

문서는 기준에 따라 텍스트를 결합 1

사용자 정의 함수를 사용하여 기준에 따라 텍스트 연결

Excel 용 Kutools를 사용하여 기준에 따라 텍스트 연결


텍스트를 고유 한 ID 번호와 결합하려면 먼저 고유 한 값을 추출한 다음 고유 한 ID를 기반으로 이름을 결합하는 사용자 정의 함수를 만들 수 있습니다.

1. 다음 데이터를 예로 들어, 먼저 고유 ID 번호를 추출해야합니다.이 배열 수식을 적용하십시오. =IFERROR(INDEX($A$2:$A$15, MATCH(0,COUNTIF($D$1:D1, $A$2:$A$15), 0)),""),이 공식을 빈 셀 (예 : D2)에 입력 한 다음 Ctrl + Shift + Enter 함께 키, 스크린 샷 참조 :

문서는 기준에 따라 텍스트를 결합 2

: 위의 공식에서 A2 : A15 고유 값을 추출하려는 목록 데이터 범위입니다. D1 추출 결과를 내고자하는 열의 첫 번째 셀입니다.

2. 그런 다음 채우기 핸들을 아래로 끌어 공백이 표시 될 때까지 모든 고유 값을 추출합니다. 스크린 샷을 참조하십시오.

문서는 기준에 따라 텍스트를 결합 3

3. 이 단계에서는 사용자 정의 기능 고유 한 ID 번호를 기준으로 이름을 결합하려면 ALT + F11 키가 열립니다. 응용 프로그램 용 Microsoft Visual Basic 창.

4. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 기준에 따라 텍스트 연결

Function ConcatenateIf(CriteriaRange As Range, Condition As Variant, ConcatenateRange As Range, Optional Separator As String = ",") As Variant
'Updateby Extendoffice
Dim xResult As String
On Error Resume Next
If CriteriaRange.Count <> ConcatenateRange.Count Then
    ConcatenateIf = CVErr(xlErrRef)
    Exit Function
End If
For i = 1 To CriteriaRange.Count
    If CriteriaRange.Cells(i).Value = Condition Then
        xResult = xResult & Separator & ConcatenateRange.Cells(i).Value
    End If
Next i
If xResult <> "" Then
    xResult = VBA.Mid(xResult, VBA.Len(Separator) + 1)
End If
ConcatenateIf = xResult
Exit Function
End Function

5. 그런 다음이 코드를 저장하고 닫고 워크 시트로 돌아가이 수식을 셀 E2에 입력합니다. = CONCATENATEIF ($ A $ 2 : $ A $ 15, D2, $ B $ 2 : $ B $ 15, ",") , 스크린 샷 참조 :

문서는 기준에 따라 텍스트를 결합 4

6. 그런 다음 채우기 핸들을이 수식을 적용하려는 셀로 드래그하면 해당하는 모든 이름이 ID 번호를 기반으로 결합되었습니다. 스크린 샷을 참조하십시오.

문서는 기준에 따라 텍스트를 결합 5

팁 :

1. 위의 공식에서 A2 : A15 결합하려는 원본 데이터입니다. D2 추출한 고유 한 값입니다. B2 : B15 함께 결합하려는 이름 열입니다.

2. 보시다시피 쉼표로 구분 된 값을 조합하여 필요에 따라 수식의 쉼표 ","를 변경하여 다른 문자를 사용할 수 있습니다.


당신이 있으면 Excel 용 Kutools그와 고급 결합 행 유틸리티를 사용하면 기준에 따라 텍스트 기반을 빠르고 편리하게 연결할 수 있습니다.

Excel 용 Kutools : 300 개 이상의 편리한 Excel 추가 기능으로 30 일 동안 제한없이 무료로 사용해 볼 수 있습니다..

설치 후 Excel 용 Kutools, 다음 단계를 수행하십시오.

1. 하나의 열을 기준으로 결합 할 데이터 범위를 선택합니다.

2. 딸깍 하는 소리 쿠툴 > 병합 및 분할 > 고급 결합 행, 스크린 샷 참조 :

3. 에서 열을 기준으로 행 결합 대화 상자에서 ID 열을 클릭 한 다음 기본 키 이 열을 결합 된 데이터의 기반이되는 키 열로 만들려면 스크린 샷을 참조하십시오.

문서는 기준에 따라 텍스트를 결합 7

4. 그런 다음 성함 값을 결합하려는 열을 클릭 한 다음 결합 옵션을 선택하고 결합 된 데이터에 대해 하나의 구분 기호를 선택합니다. 스크린 샷을 참조하십시오.

문서는 기준에 따라 텍스트를 결합 8

5. 이 설정을 마친 후 OK 대화 상자를 종료하고 B 열의 데이터는 키 A 열을 기준으로 결합되었습니다. 스크린 샷 참조 :

문서는 기준에 따라 텍스트를 결합 9

이 기능을 사용하면 가능한 한 빨리 다음 문제가 해결됩니다.

여러 행을 하나로 결합하고 Excel에서 중복을 합하는 방법은 무엇입니까?

Excel 용 Kutools를 지금 다운로드하고 무료로 평가하십시오!


Excel 용 Kutools: 300 개 이상의 편리한 Excel 추가 기능으로 30 일 동안 제한없이 무료로 사용해 볼 수 있습니다. 지금 다운로드 및 무료 평가판!

최고의 사무 생산성 도구

🤖 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 (38)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Great function! Is there a way to maintain the format in the cell it's concatenating data from? i.e. $45.07, $555.34, $0.00, $0.25, -$12.25 I've figured out how to stack them with wrap text and CHAR(10) in place of "," but having trouble keeping the format. I will be using this for a mail merge in Word.
This comment was minimized by the moderator on the site
Hello, Laurie,If you want to keep the cell formatting when concatenating the data, you can apply the Advanced Combine Rows feature of Kutools for Excel, in the dialog box, after finishing the settings, you just need to check Use formatted values option, and all the data formatting will be kept as you need.
You can download Kutools for Excel and free trial 30-day.
This comment was minimized by the moderator on the site
Is there any way to add "and" instead of "," before the last data? (For example: D2355, D2273, D2397, D2600 and D2386)
This comment was minimized by the moderator on the site
Hi, Hossain,May be there is not a direct method for solving your problem, you can add another formula to convert the last comma to the text "and".=SUBSTITUTE(E2,","," and ",LEN(E2)-LEN(SUBSTITUTE(E2,",","")))
Please try, thank you!
This comment was minimized by the moderator on the site
It worked like a charm sir. Thank you so much.
This comment was minimized by the moderator on the site
Great function, exactly what I needed! Works like a charm
This comment was minimized by the moderator on the site
Hi,

Very helpful VBA solution. Thank you kindly! My question is: Is there a way to change the code or function for multiple criteria? Although the code works for me, I need it to show values corresponding to a timestamp-interval (>= timestamp A, <= timestamp B)


Thank you in advance. :)
This comment was minimized by the moderator on the site
Is there a way to assign this to a button? On large data ranges it takes a while, so ideally I only want it to start the concatenate process once I've finished doing everything else in the sheet. I tried adding a trigger myself but it stopped working completely
This comment was minimized by the moderator on the site
BTW i used the VBA solution
This comment was minimized by the moderator on the site
Extremely helpfull! After editing it for my sheet i have #VALUE! for some of the unique values.
I did a countif to see if it could be that there are too many names to concatenate. The two unique values that have the #VALUE! error have 13635 and 19810 results. Is there a way to overcome this?
This comment was minimized by the moderator on the site
How can I ignore blank cells? mine currently displays this:

";;;;;;;;;"

I'd like for the 1st, 3rd and last 3 semi colons not to there/show. TIA
This comment was minimized by the moderator on the site
Hello, Chantelle
When concatenating the cell values ignoring the blank cells, please apply the below User Defined Function:

Function ConcatenateIf(CriteriaRange As Range, Condition As Variant, ConcatenateRange As Range, Optional Separator As String = ",") As Variant
Dim xResult As String
On Error Resume Next
If CriteriaRange.Count <> ConcatenateRange.Count Then
ConcatenateIf = CVErr(xlErrRef)
Exit Function
End If
For i = 1 To CriteriaRange.Count
If CriteriaRange.Cells(i).Value = Condition Then
If ConcatenateRange.Cells(i).Value <> "" Then
xResult = xResult & Separator & ConcatenateRange.Cells(i).Value
End If
End If
Next i
If xResult <> "" Then
xResult = VBA.Mid(xResult, VBA.Len(Separator) + 1)
End If
ConcatenateIf = xResult
Exit Function
End Function

Please try it, hope it can help you!
This comment was minimized by the moderator on the site
thank you very much! This was so simple and helped a lot!!
This comment was minimized by the moderator on the site
Is it possible to replace the comma splitter with a line break, i.e. char(10)? Many thanks.
This comment was minimized by the moderator on the site
Hello, David,

To combine the cells with line break, the following User Defined Function may help you.

Function ConcatenateIf_LineBreak(CriteriaRange As Range, Condition As Variant, ConcatenateRange As Range, Optional Separator As String = ",") As Variant
Dim xResult As String
On Error Resume Next
If CriteriaRange.Count <> ConcatenateRange.Count Then
ConcatenateIf = CVErr(xlErrRef)
Exit Function
End If
For I = 1 To CriteriaRange.Count
If CriteriaRange.Cells(I).Value = Condition Then
xResult = xResult & vbCrLf & ConcatenateRange.Cells(I).Value
End If
Next I
If xResult <> "" Then
xResult = VBA.Mid(xResult, VBA.Len(Separator) + 1)
End If
ConcatenateIf_LineBreak = xResult
Exit Function
End Function

After pasting this code, then apply this formula: =ConcatenateIf_LineBreak(A2:A13,F2,B2:B13,",").

After getting the results with this formula, you should click the Wrap Text to get the correct results you need.
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