+ Reply to Thread
Results 1 to 5 of 5

Combining Text split across uneven number of rows

  1. #1
    Registered User
    Join Date
    07-23-2012
    Location
    My Desk, Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Combining Text split across uneven number of rows

    Slightly More Complicated this time.

    I receive some data from an outside agency in a PDF, they refuse to send me the excel sheet, they insist on typing it up.

    I've copied this PDF into excel, but its splitting the line of text across two, sometimes three rows

    The final row, will always start "Claim"

    If did an B1=left(A1,5) to pull out if its a claim or not, and then did C3=IF(B3="claim",A1&A2&A3,"")

    But that doesnt work for two row claims, just three row

    I'm thinking I can do an C3=If(B3="claim",If(B1="claim" to determine if its a two or three row entry.

    Does that sound like it will work?
    Is there a better way?

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combining Text split across uneven number of rows

    It will be good if you attach a sample file.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-23-2012
    Location
    My Desk, Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Combining Text split across uneven number of rows

    Cant really attach a file, its all data protected.

    But here goes

    Pork Sausages
    Beef Sausges
    Claim
    Pork Sausages
    Claim
    Beef Sausges
    Claim
    Pork Sausages
    Beef Sausges
    Claim

    If you copy that into cells A1:A10
    I then use Left(5) to pull out claim (And "Pork ", and "Beef " into Cols B1:10)

    I now want C3 to return "Pork Sausages Beef Sausages Claim"
    Which I can do

    But I want C5 to return "Pork Sausages Claim", instead I am getting "Claim Pork Sausages Claim"


    =IF(B5="claim",A3&A4&A5,)
    Works Fine, for three row problems.

    If its a two row problem, I only need cells A4 and A5.
    I thought i could solve this, by asking
    =IF(B5="claim",IF(B3=”claim”,A4&A5,A3&A4&A5),A3&A4&A5)

    But it doesnt like the second claim, throws it out as an error

    I suppose I could accept "Claim Pork Sausages Claim" and use Column D pull out everything after the first claim, but I'm hoping there is a more elegant way (and I didnt think of that till right then)

    ---------- Post added at 10:01 AM ---------- Previous post was at 09:34 AM ----------

    I've done it that way
    So Col B pulls out Claim
    Col C finds "claim" in B, and pulls out three rows
    Col D finds "claim in B and pulls out two rows.
    Col E pulls out the first 5 from the left of C
    Col F checks E, and if its Claim, I know its a two row problem, so can pull out D5, otherwise, C5

    B3=LEFT(A3,5)
    C3=IF(B3="claim",A1&A2&A3,"")
    D3=IF(B3="Claim",A2&A3,"")
    E3=LEFT(C3,5)
    F3=IF(E3="Claim",D3,C3)

    If anyone has a prettier way, I'm happy to be informed

  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: Combining Text split across uneven number of rows

    i can extract what you want but not quite where you wanted it see attached
    Attached Files Attached Files
    "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
    Registered User
    Join Date
    07-23-2012
    Location
    My Desk, Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Combining Text split across uneven number of rows

    Fantastic
    Thanks

+ 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