+ Reply to Thread
Results 1 to 13 of 13

Concatenating Columns values

  1. #1
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    Concatenating Column values

    I'm new to VB and want to know how does it work for merging cells with common values and concatenate values is they are different in an excel sheet.

    For ex below is the sheet with the values

    A B C D E
    1 2 3 4 5
    1 2 4 5 6
    1 2 4 5 6

    and I want the script to produce an output like

    A
    1

    B
    2

    C
    3,4

    D
    4,5

    E
    5,6

    Can anyone please help me in achieving the above result using vb script.

    Thanks in advance.
    Last edited by sarathyvb; 10-24-2007 at 07:02 PM.

  2. #2
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    I am nor sure what the result you want is from the example, can you restate the problem, the solution will be straightforward i think , but i am not clear what you want exactly

    Regards

    dav

  3. #3
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    Combine Values

    The requirement is to check the number of cells that are common in column A and Column B, merge them to one row and concatenate the rest of the column values using "," for the other cells C, D and E.

    Attached zip file has an excel sheet in which sheet1 has the actual values and sheet2 has the values combined values for which I'm looking for. And I need the vb script for doing so.
    Attached Files Attached Files
    Last edited by sarathyvb; 10-24-2007 at 07:04 PM.

  4. #4
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    Apart from the fact you have the id number for 2 of your values in the sheet, is this what you require

    Let me know

    Regards

    Dav
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    Clarify

    Sorry, I was not able to grasp your point. But to make it clear here is what I want, in an excel sheet I have to look up for column values in A and B with similar values and if found those should be made as a single row by concatenating the rest of the column values using comma.

    Hope this helps. Also have attached a jpg for better understanding, where table 1 is the data that I receive and table 2 should be the output created by script.
    Attached Images Attached Images

  6. #6
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    I have added a button

    I assume you have the excel options set to allow macros

    Click the button on sheet 2

    Does that help

    regards

    Dav
    Attached Files Attached Files
    Last edited by Dav; 10-25-2007 at 11:18 AM.

  7. #7
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    Thanks a ton

    Dav,

    This is what I was looking for and thanks a ton for helping me out with the script.

    If possible can you help me in doing the same by using a for loop for columns also as you did for rows.

    Anyways Thanks again and appreciated for getting this done.

  8. #8
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    columns are much the same as rows. what are you wanting to do?

    Regards

    Dav

  9. #9
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    VB Script

    Dav thanks for providing me the macro.

    Can anyone please help me in resolving the problem in the below script, the concatenating part is working fine using the Match function, but the problem I have is I'm not sure how to delete the rows that have been concatenated. I tried using the "ActiveCell.EntireRow.Delete" but it is not working as expected. If someone could help me out in this it will be great.

    Thanks in advance.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 10-30-2007 at 06:12 PM.

  10. #10
    Registered User
    Join Date
    10-17-2007
    Posts
    8

    Can anyone help me out????

    Can anyone please have a look at the above thread and let me know the appropriate delete statement that has to be used.

    Thanks

  11. #11
    Forum Contributor
    Join Date
    12-12-2006
    Location
    New Zealand
    Posts
    151
    You need to use code tags for your code.

    It makes it a lot easier for us to read it. It gives me a headache looking at it like that so Im not going to but heres one way to delete rows:

    Please Login or Register  to view this content.

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I tried using the "ActiveCell.EntireRow.Delete" but it is not working as expected.
    What does it do that you don't want or not do that you do want?

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    This post has gone far afield of the original question.

    Why are you creating a new instance of Excel instead of opening the workbook in the current instance?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1