+ Reply to Thread
Results 1 to 5 of 5

Concatenate address lines of varying number

  1. #1
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Concatenate address lines of varying number

    I am trying to concatenate lines of addresses.

    There are two problems:
    1. The first line could start in a different row each time
    2. The number of lines varies

    I have sorted the first issue by matching the line that says 'Address', then offsetting by one row.

    I have a formula to determine the number of lines by subtracting the last row of address from the first row (the cell after the last line contains the text "Customer contact details").

    In this instance, I could use nested if statements for every permutation, but is there a better way?

    Thanks in advance.
    Attached Files Attached Files
    Last edited by tone640; 08-08-2011 at 09:50 AM.

  2. #2
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Concatenate address lines of varying number

    Bump - any ideas?

  3. #3
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Concatenate address lines of varying number

    I have solved this with IF statements:

    =IF(MATCH("customer contact details",Sheet3!A:A,0)-MATCH("address:",Sheet3!A:A,0)=3,OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),1,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),2,0),IF(MATCH("customer contact details",Sheet3!A:A,0)-MATCH("address:",Sheet3!A:A,0)=4,OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),1,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),2,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),3,0),IF(MATCH("customer contact details",Sheet3!A:A,0)-MATCH("address:",Sheet3!A:A,0)=5,OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),1,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),2,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),3,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),4,0),IF(MATCH("customer contact details",Sheet3!A:A,0)-MATCH("address:",Sheet3!A:A,0)=6,OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),1,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),2,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),3,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),4,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),5,0),OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),1,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),2,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),3,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),4,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),5,0)&", "&OFFSET(INDIRECT("sheet3!"&"A"&MATCH("address:",Sheet3!A:A,0)),6,0)))))

    This has the following limitations:
    1. It only works in 2007 format (it exceeds reference limits on earlier versions).
    2. It only works with 2 to 6 lines of address - if I were applying this to other lists with more lines, it would not work. Is there a way of making this work with x number of lines?
    3. It is a mess!

    Any help or suggestions to improve this would be much appreciated.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by tone640; 08-08-2011 at 05:43 AM. Reason: Updated attachment

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Concatenate address lines of varying number

    id probably do this then you can just put your sheet names in column a ,still uses indirect but gets rid of offset. you can just hide the columns c:i , or do that whole bit on another sheet out of sight as in concat address maybe(1)
    Attached Files Attached Files
    Last edited by martindwilson; 08-08-2011 at 08:11 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Concatenate address lines of varying number

    Thanks for your help, I'll try this.

+ 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