How To Concatenate Cells If Same Value Exists in Another Column in Excel?
How To Concatenate Cells If Same Value Exists in Another Column in Excel?
1/7/22, 12:09
Note: The other languages of the website are Google-translated. Back to English
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
value.html)
! ExtendOffice (https://www.extendoffice.com)
Products Download (/download.html) Purchase
Resources Support (/support.html) Languages
!
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 1 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
With the below formulas, you can concatenate corresponding cell contents if another
column contains same value in Excel.
1. Select a blank cell besides the second column (here we select cell C2), enter
formula =IF(A2<>A1,B2,C1 & "," & B2) into the formula bar, and then press the Enter
key.
2. Then select cell C2, and drag the Fill Handle down to cells you need to
concatenate.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 2 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
4. Select cell D1, and click Data > Filter. See screenshot:
5. Click the drop-down arrow in cell D1, uncheck the (Blanks) box, and then click the
OK button.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 3 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
You can see the cells are concatenated if the first column values are same.
Note: To use the above formulas successfully, the same values in column A must be
continuous.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 4 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
Besides formula, in this section, we will show you how to use VBA code to
concatenate cells if same value.
1. Press Alt + F11 keys to open the Microsoft Visual Basic Applications window.
2. In the Microsoft Visual Basic Applications window, click Insert > Module. Then
copy and paste below code into the Module window.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 5 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
1 Sub ConcatenateCellsIfSameValues()
2 Dim xCol As New Collection
3 Dim xSrc As Variant
4 Dim xRes() As Variant
5 Dim I As Long
6 Dim J As Long
7 Dim xRg As Range
8 xSrc = Range("A1", Cells(Rows.Count, "A").End(xlUp)).Resiz
9 Set xRg = Range("D1")
10 On Error Resume Next
11 For I = 2 To UBound(xSrc)
12 xCol.Add xSrc(I, 1), TypeName(xSrc(I, 1)) & CStr(xSrc(I,
13 Next I
14 On Error GoTo 0
15 ReDim xRes(1 To xCol.Count + 1, 1 To 2)
16 xRes(1, 1) = "No"
17 xRes(1, 2) = "Combined Color"
18 For I = 1 To xCol.Count
19 xRes(I + 1, 1) = xCol(I)
20 For J = 2 To UBound(xSrc)
21 If xSrc(J, 1) = xRes(I + 1, 1) Then
Notes:
1. D1 in line Set xRg = Range("D1") means that the result will be placed in cell D1.
3. Press the F5 key to run the code, then you will get the concatenated results in
specified range.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 6 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
If the above two methods are complicated for you, here we will show you the
Advanced Combine Rows utility of Kutools for Excel. You can easily concatenate
cells by comma, semicolon and so on if same values exist in another column.
Before applying Kutools for Excel, please download and install it firstly
(/download/kutools-for-excel.html).
1. Select the range with cells you need to concatenate, and then click Kutools >
Merge & Split > Advanced Combine Rows. See screenshot:
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 7 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
2.1) Select the column with same value you want to concatenate cells based on,
and then click the Primary Key button.
2.2) Select the column you want to concatenate the cells, click Combine button,
and then specify a separator from the context menu (here I specify Comma).
2.3) Click the OK button.
Now the cells are concatenated according to the primary key column.
If you want to have a free trial ( 30-day) of this utility, please click to
download it (/download/kutools-for-excel.html), and then go to apply the
operation according above steps.
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 8 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
Facebook Watch
Kutools For Excel Solves Most Of Your Problems, And Increases Your
Productivity By 80%
Reuse: Quickly insert complex formulas, charts and anything that you have
used before; Encrypt Cells with password; Create Mailing List and send emails...
Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout
(easily read and edit large numbers of cells); Paste to Filtered Range...
Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine
Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super
Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create
References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print
Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by
month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 9 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel 2007-2019 and 365.
Supports all languages. Easy deploying in your enterprise or organization. Full
features 30-day free trial. 60-day money back guarantee.
(/download/kutools-for-excel.html)
Office Tab Brings Tabbed Interface To Office, And Make Your Work
Much Easier
Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher,
Access, Visio and Project.
Open and create multiple documents in new tabs of the same window, rather than
in new windows.
Increases your productivity by 50%, and reduces hundreds of mouse clicks for you
every day!
(/download/office-tab.html)
Oldest First #
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 10 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
cathy postmus
about 6 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
· #16504
value.html#comment-16504,0T
Can't seem to concatenate with more than 2 cells using formulas and
filters
Reply
Geoffrey saya
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #20935
same-value.html#comment-20935,0T
How can i merge collums with the same names eg Column one reads
Kenya throughout and collumn 2 reads western, Nyanza( appearing
more than ten times) and column 3 three names of districts. I want to
get how mang districts do we have in every province but keep the
columns.
Reply
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 11 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(/forum/profile/4614b
crystal (/forum/profile/4614-crystal.html) $ Geoffrey saya
crystal.html)
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-
· #20936
if-same-value.html#comment-20936,20935T
Dear Geoffrey,
After that, you will get how many district you have in every
province.
Reply · Report
Marissa W
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
· #21720
value.html#comment-21720,0T
The concatenate feature does not work. Combines all the rows into
one cell despite different keys.
Reply
(/forum/profile/4614b
crystal (/forum/profile/4614-crystal.html) $ Marissa W
crystal.html)
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #21721
same-value.html#comment-21721,21720T
Dear Marissa,
Sorry I am not sure I got your question. There are three methods
in the article, which concatenate feature do you mean?
Reply · Report
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 12 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
RS
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
· #23817
value.html#comment-23817,0T
Reply
Ram
about 4 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #25283
same-value.html#comment-25283,0T
Reply
(/forum/profile/12212b
Matt Carrington (/forum/profile/12212-travelermatt.html)
travelermatt.html)
about 3 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
· #26110
value.html#comment-26110,0T
Using the VBA macro and getting great results, I have tried tweaking it
slightly for my needs but cant get it to work so I hope you can help.
Which bit do I change to make it concat a specific column, not the one
directly to the right of the xSrc f Range?
Reply · Report
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 13 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(/forum/profile/12212b
Matt Carrington (/forum/profile/12212-travelermatt.html) $
travelermatt.html)
Matt Carrington (/forum/profile/12212-travelermatt.html)
about 3 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #26111
same-value.html#comment-26111,26110T
Reply · Report
James
about 3 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #26698
same-value.html#comment-26698,0T
I use this VBA for lots of my spreadsheets and its great. But the
spreadsheets have become very large 50k+ rows and it doesnt seem
to be working any more. If I use it on 1000 rows it works fine but large
sets of data it cant seem to cope with. No errors just no results. Any
help would be appreciated.
Reply
(/forum/profile/4614b
crystal (/forum/profile/4614-crystal.html) $ James
crystal.html)
about 3 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-
· #26699
if-same-value.html#comment-26699,26698T
Hi James,
I tested the code as you mentioned, but it still works well in my
case even I set the rows to 1000l.
Reply · Report
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 14 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(/forum/profile/18549b
Harry Vyvey (/forum/profile/18549-harryvyvey.html)
harryvyvey.html)
about 3 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #29669
same-value.html#comment-29669,0T
Hi,
kind regards
Harry
Reply · Report
(/forum/profile/18954b
Jade (/forum/profile/18954-jadee.html)
jadee.html)
about 2 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #30225
same-value.html#comment-30225,0T
Hi, first of all thanks for creating this resource. I have been trying to
figure this out for a couple of hours and I'm stuck. I'm using your
'concatenate cells if same value' but my script is looking at column "D"
instead of "A. I can't figure out how to get it to use a different column
for the data besides the one right next to it. In my cases I want it to
look at column "D" to see if the value is the same and if so, it will grab
the data from column "H" and put that data from column "H' into a cell
in column "J". How do I switch this to use column "H" for the data? Thx
Sub ConcatenateCellsIfSameValues()
Dim xCol As New Collection
Dim xSrc As Variant
Dim xRes() As Variant
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 15 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
Dim I As Long
Dim J As Long
Dim xRg As Range
xSrc f Range("D1", Cells(Rows.Count, "D").End(xlUp)).Resize(, 2)
Set xRg f Range("J1")
On Error Resume Next
For I f 2 To UBound(xSrc)
xCol.Add xSrc(I, 1), TypeName(xSrc(I, 1)T & CStr(xSrc(I, 1))
Next I
On Error GoTo 0
ReDim xRes(1 To xCol.Count l 1, 1 To 2T
xRes(1, 1) = "No"
xRes(1, 2) = "Products"
For I f 1 To xCol.Count
xRes(I l 1, 1T f xCol(I)
For J f 2 To UBound(xSrc)
If xSrc(J, 1) = xRes(I l 1, 1T Then
xRes(I l 1, 2T f xRes(I l 1, 2T & vbCrLf & xSrc(J, 2)
End If
Next J
xRes(I l 1, 2T f Mid(xRes(I l 1, 2T, 2T
Next I
Set xRg = xRg.Resize(UBound(xRes, 1T, UBound(xRes, 2TT
xRg.NumberFormat = "@"
xRg = xRes
xRg.EntireColumn.AutoFit
End Sub
Reply · Report
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 16 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(/forum/profile/30029b
mcaldw (/forum/profile/30029-mcaldw.html) $
mcaldw.html)Jade (/forum/profile/18954-jadee.html)
about 2 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-
· #30226
if-same-value.html#comment-30226,30225T
"I can't figure out how to get it to use a different column for the
data besides the one right next to it. In my cases I want it to look
at column 'D' to see if the value is the same and if so, it will grab
the data from column 'H' and put that data from column 'H' into a
cell in column 'J'."
Reply · Report
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 17 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
EZPD
about 2 years ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-
· #32701
value.html#comment-32701,0T
I just wanted to thank you. It wasn't exactly what I wanted but man did
it help me figure out what to do.
Reply
Kristin
about 8 months ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-
· #36409
same-value.html#comment-36409,0T
Hello, how would the VBA code be adjusted if I want to combine cells
in column M based on the duplicates in column A?
Reply
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 18 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(/forum/profile/4614b
crystal (/forum/profile/4614-crystal.html) $ Kristin
crystal.html)
about 7 months ago
(https://www.extendoffice.com/documents/excel/3153-excel-concatenate-
· #36410
if-same-value.html#comment-36410,36409T
On Error GoTo 0
ReDim xRes(1 To xCol.Count l 1, 1 To 2T
xRes(1, 1) = "No"
xRes(1, 2) = "Combined Color"
For I f 1 To xCol.Count
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 19 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
xRes(I l 1, 1T f xCol(I)
For J f 2 To UBound(xSrc)
If xSrc(J, 1) = xRes(I l 1, 1T Then
xRes(I l 1, 2T f xRes(I l 1, 2T & ", " & xSrcValue(J, 1)
End If
Next J
xRes(I l 1, 2T f Mid(xRes(I l 1, 2T, 2T
Next I
Set xRg = xRg.Resize(UBound(xRes, 1T, UBound(xRes, 2TT
xRg.NumberFormat = "@"
xRg = xRes
xRg.EntireColumn.AutoFit
End Sub
Reply · Report
- -
% & ' ( " -
) * + -
,
- -
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 20 of 21
How to concatenate cells if same value exists in another column in Excel? 1/7/22, 12:09
(http://www.facebook.com/extendoffice)
(http://twitter.com/intent/follow?
source=followbutton&variant=1.0&screen_name=extendoffice)
Copyright © 2009 - 2022 www.extendoffice.com | All Rights Reserved. / Sitemap
(/support/sitemap.html)
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft
Corporation in the United States and/or other countries.
Kutools for Excel Solves Most(https://sectigo.com/trust-seal)
of Your Problems, and Increases
Your Productivity Byi (https://www.addthis.com/website-tools/overview?
80%. Full Features 30-day Free Trial.
utm_source=AddThis%20Tools&utm_medium=image&utm_campaign=Marketing%20tool%20logo)
https://www.extendoffice.com/documents/excel/3153-excel-concatenate-if-same-value.html Page 21 of 21