Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8861231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:26:51+00:00 2026-06-14T15:26:51+00:00

I apologise if this question already exists, I searched for a while but couldn’t

  • 0

I apologise if this question already exists, I searched for a while but couldn’t find anything.

I have 2 columns in Excel and I need to concatenate the values of 1 column where the values of another are the same. As an example I have this:

A  | B
12 | Value 1
10 | Value 2
13 | Value 3
12 | Value 4
10 | Value 5

And I would like to get out:

A  | B
12 | Value 1, Value 4
10 | Value 2, Value 5
13 | Value 3

I have thousands of rows and ideally I would like it to create a new worksheet with the results and not destroy the existing sheet. There are also some blank values in column B which I would like it to ignore and not concatenate.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:26:52+00:00Added an answer on June 14, 2026 at 3:26 pm

    Try this:

    Sub combineValues()
        Dim dic As Dictionary
        Dim key, val, i, p, k
        Set dic = New Dictionary
        For i = 1 To Worksheets(1).Range("A65536").End(xlUp).Row
            key = Worksheets(1).Cells(i, 1).Value
            val = Worksheets(1).Cells(i, 2).Value
            If dic.Exists(key) Then
                dic.Item(key) = dic.Item(key) & ", " & val
            Else
                dic.Add key, val
            End If
        Next
        p = 1
        For Each k In dic.Keys
            Worksheets(2).Cells(p, 1) = k
            Worksheets(2).Cells(p, 2) = dic.Item(k)
            p = p + 1
        Next
    End Sub
    

    Note that you’ll have to include “Microsoft Scripting Runtime” in “Reference” in order to use Dictionary.

    Tested with following [Sheet 1]:

    1   value 1
    2   value 2
    3   value 3
    1   value 4
    1   value 5
    3   value 6
    3   value 7
    2   value 8
    1   value 9
    2   value 10
    2   value 11
    2   value 12
    

    Results in following [Sheet 2]:

    1   value 1, value 4, value 5, value 9
    2   value 2, value 8, value 10, value 11, value 12
    3   value 3, value 6, value 7
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if I missed this question already, but I searched and couldn't find it.
I apologize if this question was asked already before but I could not find
I apologize if this question was already asked but I can't seem to find
I apologise if this question has already been asked on here before but I
First off, I apologize if this question has already been asked. I searched but
Apologies if this question has been asked already, but suppose we have this code
I didn't find a similar question, so I apologize if it already exists. In
I apologise if this question has already been asked. I'm really new to Python
I apologize if this question has been answered already, but I cannot seem to
Apologies if this question is already posted. I didn't find the answer i was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.