+ Reply to Thread
Results 1 to 10 of 10

Two Rows Into One?

  1. #1
    Registered User
    Join Date
    03-14-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Two Rows Into One?

    Hi guys, new to the forum so please be gentle with me!

    I'm currently trying to work out the best way of condensing data on a worksheet. At present each individual product (there's 1164 of them in total) occupy's two rows - one containing a colour name and the other containing an image ref. I'm looking for the easiest way to coverge the two rows of data into one, so that each product's data is then only on one line but on a seperate worksheet.

    To complicate matters a little further, when the data is transposed it needs to be alternate.

    Example:

    Before
    PRODUCTS_5400_30959.jpg GM013 Black Light Blue Navy
    OPTIONS_50636_38898.jpg OPTIONS_50637_38899.jpg OPTIONS_50638_38900.jpg

    After
    PRODUCTS_5400_30959.jpg GM013 Black OPTIONS_50636_38898.jpg Light Blue OPTIONS_50637_38899.jpg Navy OPTIONS_50638_38900.jpg

    As already mentioned, there's a total of 1164 products (so currently 2328 rows of data) which i need to manipulate, so the more automated the better.

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Two Rows Into One?

    If your data starts in cell A1 then try this formula:

    =OFFSET($A$1,MOD((COLUMN(A:A)-1),2),INT((COLUMN(A:A)-1)/2))

    As you drag it across it will alternate rows to product the data you want. The section in bold is the bit that needs to be changed to work with data in a different range of cells.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Two Rows Into One?

    I think your only going to be able to achieve this with VBA. The sticking point will be knowing if a colour consists of one or two words so as to know where to insert the options text. The easiest way round this would be to start off changing all colours consisting of two words to one like Light_Blue.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Registered User
    Join Date
    03-14-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Two Rows Into One?

    Quote Originally Posted by Zoskie View Post
    Hi guys, new to the forum so please be gentle with me!

    I'm currently trying to work out the best way of condensing data on a worksheet. At present each individual product (there's 1164 of them in total) occupy's two rows - one containing a colour name and the other containing an image ref. I'm looking for the easiest way to coverge the two rows of data into one, so that each product's data is then only on one line but on a seperate worksheet.

    To complicate matters a little further, when the data is transposed it needs to be alternate.

    Example:

    Before
    PRODUCTS_5400_30959.jpg GM013 Black Light Blue Navy
    OPTIONS_50636_38898.jpg OPTIONS_50637_38899.jpg OPTIONS_50638_38900.jpg

    After
    PRODUCTS_5400_30959.jpg GM013 Black OPTIONS_50636_38898.jpg Light Blue OPTIONS_50637_38899.jpg Navy OPTIONS_50638_38900.jpg

    As already mentioned, there's a total of 1164 products (so currently 2328 rows of data) which i need to manipulate, so the more automated the better.

    Thanks in advance
    Sorry guys, my example wasn't very clear on reviewing.

    The information for each product is on two seperate rows AND multiple columns - as per attached. Excel Test.xlsx

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Two Rows Into One?

    If you modify my formula to:

    =OFFSET(Sheet1!$A1,MOD((COLUMN(A:A)-1),2),INT((COLUMN(A:A)-1)/2))

    And paste that into cell A1 of sheet 2 in your example, and then drag across, it should work fine.

  6. #6
    Registered User
    Join Date
    03-14-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Two Rows Into One?

    Quote Originally Posted by Andrew-R View Post
    If you modify my formula to:

    =OFFSET(Sheet1!$A1,MOD((COLUMN(A:A)-1),2),INT((COLUMN(A:A)-1)/2))

    And paste that into cell A1 of sheet 2 in your example, and then drag across, it should work fine.
    Many thanks for your help Andrew-R.

    Would the formula you're suggesting result in this: Excel Test.xlsx ?

    Again thanks in advance,

    Zoskie

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Two Rows Into One?

    Not quite.

    The formula to get you that result is:

    =IF(COLUMN(A:A)<3,OFFSET(Sheet1!$A$1,INT(ROW(1:1)-1)*2,COLUMN(A:A)-1),OFFSET(Sheet1!$C$1,MOD(COLUMN(A:A)-3,2)+((ROW(1:1)-1)*2),INT((COLUMN(A:A)-3)/2)))

    In cell A1 of sheet2, copied across and down.

  8. #8
    Registered User
    Join Date
    03-14-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Two Rows Into One?

    That's absolutely fantastic!!

    Many, many thanks for your help and assistance, that's exactly what i've been looking for and trying to implement for days.

    Just out of curiosity .... obviously the rows end up at different lengths as products have differing SKU's (in this case colours) which results in a number of cells containing "0". Can the formula be modified in any way to ignore "0" rated cells, therefore leaving them blank?

    Once again many thanks,

    Zoskie

  9. #9
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Two Rows Into One?

    Yes, we can do that, but it's not pretty ...

    =IF(COLUMN(A:A)<3,OFFSET(Sheet1!$A$1,INT(ROW(1:1)-1)*2,COLUMN(A:A)-1),IF(OFFSET(Sheet1!$C$1,MOD(COLUMN(A:A)-3,2)+((ROW(1:1)-1)*2),INT((COLUMN(A:A)-3)/2))="","",OFFSET(Sheet1!$C$1,MOD(COLUMN(A:A)-3,2)+((ROW(1:1)-1)*2),INT((COLUMN(A:A)-3)/2))))

    Should be it.

  10. #10
    Registered User
    Join Date
    03-14-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Two Rows Into One?

    Quote Originally Posted by Andrew-R View Post
    Yes, we can do that, but it's not pretty ...
    It doesn't have to be prety, as long as it gets the job done ...... which it has!

    Yet again Andrew, many thanks for all your help and assistance in offering a solution to my problem. If only i'd registered on the forum weeks ago!!!

    Zoskie

+ 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