+ Reply to Thread
Results 1 to 5 of 5

Concatenate cells or ranges based on conditions

  1. #1
    Registered User
    Join Date
    10-01-2009
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Concatenate cells or ranges based on conditions

    Im not sure what you call what i want to do, if anyone can let me know. Its a simple thing, that its slipped my mind at the moment.

    Right, Im happy to use VBA as well as the good ol' formulas.

    Here it is.

    I have a list of people to send drawings out to.
    I have already made the selections am just trying to work out how to simplify the output so as to use as a field in a data file to go onto a letter.

    eg.
    "| A01 | A02 | A03 | A04 | A05 | A06 | A07 |" are for Joe Bloggs
    ( | are cells)

    In another cell, i would like to merge them together like so

    "A01-A07" are for Joe Bloggs

    And also as follows

    "| A01 | | A03 | A04 | A05 | | A07 |" are for John Smith

    would like this to be
    "A01, A03-A05,A07" are for John Smith.

    So differing conditions depending on what happens in the range.
    I have had a couple of attempts at this using a VBA concatenate command, I can get them to display like "A01,A02,A03..." with a selected separator, but cannot get it how i want it.

    If it does involves a lot of coding, never mind, i will leave it out.

    Thank you in advance
    Last edited by andrewdaus; 10-01-2009 at 06:45 PM. Reason: Heading change

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Tricky one. Range question

    please read the forum rules and amend your thread title. you're asking how to concatenate cells or ranges based on conditions, so there's your title.

    also, it would help to see a workbook with a data sample that illustrates your layout, data input, processing logic, data output.

    cheers

  3. #3
    Registered User
    Join Date
    10-01-2009
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Concatenate cells or ranges based on conditions

    Cheers for your help thus far, thanks for referring me to the rules section, i forget to read that, like EULAs... anyways. I have attached a portion of the file that is relevant to my question including the coding i have written so far.

    The columns on the end are the end result of macro ConcatenateRange as well as the result (or similar) that I intend to have.

    I am more than happy to elaborate if any more details are required. Thanks!
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Concatenate cells or ranges based on conditions

    Not very elegant and I'm sure it could be vastly improved but based upon your sample file perhaps:

    Please Login or Register  to view this content.
    Called from cell

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-01-2009
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Concatenate cells or ranges based on conditions

    This is fantastic! Exactly what I was after! Thank you!!

+ 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