+ Reply to Thread
Results 1 to 5 of 5

Rows to Column's with a twist

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2004
    Posts
    28

    Rows to Column's with a twist

    Hi all,

    I have searched for 2 days (not 48 hours but on and off for 2 days), for the answer to this one without success.

    I have an excel sheet with the following two columns of data

    A B
    Product Size
    K19022 104CM
    K19022 106CM
    K19022 108CM
    K19022 110CM
    K19022 112CM
    K19025 86CM
    K19025 88CM
    K19025 90CM
    K19025 92CM
    K19025 94CM


    I need it to look like this instead

    A B C D E F
    Product Sizes
    K19022 104CM 106CM 108CM 110CM 112CM
    K19025 86CM 88CM 90CM 92CM 94CM


    I have 42000 rows of info like that so could do with some help as the standard transpose will take me a long time to complete.

    Not all products have 5 sizes, some have 20, some have 1.

    Can anyone help?

    Many thanks in advance.

    OKanem

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Rows to Column's with a twist

    Try this:-
    NB:- "BackUp" your data this code will delete the duplicates
    Sub MG01Oct19
    Dim Rng As Range, Dn As Range
    Dim Q
    Dim t
    Dim nRng As Range
    t = Timer
    Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
        With CreateObject("scripting.dictionary")
            .CompareMode = vbTextCompare
    For Each Dn In Rng
        If Not .Exists(Dn.Value) Then
            .Add Dn.Value, Array(Dn, 1)
        Else
            Q = .Item(Dn.Value)
                Q(1) = Q(1) + 1
                Q(0).Offset(, Q(1)) = Dn.Offset(, 1).Value
            .Item(Dn.Value) = Q
                If nRng Is Nothing Then
                    Set nRng = Dn
                Else
                    Set nRng = Union(nRng, Dn)
                End If
    
        End If
    Next
            If Not nRng Is Nothing Then nRng.EntireRow.Delete
    End With
    MsgBox Timer - t
    End Sub
    Regards Mick

  3. #3
    Registered User
    Join Date
    10-19-2010
    Location
    Chennai, Tamilnadu
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Rows to Column's with a twist

    Is solution using vba programmng is acceptable???

  4. #4
    Registered User
    Join Date
    05-10-2004
    Posts
    28

    Re: Rows to Column's with a twist

    MickG, that did the trick. thanks for the help.

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Rows to Column's with a twist

    You're welcome
    Regrds Mick

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Transpose data from rows to columns - with a slight twist
    By pettukola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2012, 07:45 PM
  2. concatenate cells and delete rows with a twist
    By rudyrod in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2009, 09:16 AM
  3. Delete Duplicate Rows, with a twist
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2008, 10:21 AM
  4. [SOLVED] Add Column Data with Twist
    By John in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2006, 03:45 AM
  5. [SOLVED] [SOLVED] Patse Rows from one Sheet to another with a Twist
    By John in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-08-2005, 02:05 AM

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