+ Reply to Thread
Results 1 to 17 of 17

Transform data to tabular format

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Transform data to tabular format

    Hello everyone

    I have the data in three columns. The first column is for the IDs and this will be unique in output in column A in output
    The second column would be the headers after the column A in output
    The third column has the values which I need to populate properly in each suitable place in the output
    The attachment will explain better than the description

    Please Login or Register  to view this content.
    Posted at this link too
    http://www.eileenslounge.com/viewtopic.php?f=30&t=34512
    Attached Files Attached Files
    Last edited by YasserKhalil; 05-01-2020 at 02:26 PM.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Transform data to tabular format


    Hi,

    like any Excel beginner can achieve this just operating manually you can start for example with an advanced filter to create the first column …
    Check your attachment as with an error that can confuse any helper will.
    Last edited by Marc L; 05-01-2020 at 02:07 PM. Reason: typo …

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    The problem is not in the first column as I can get the unique items easily using the dictionary. The problem for me is how to make the headers dynamic to fit all the values for all the names ..Hope to get a solution. I have spent about three hours trying to solve it.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    Any help in this topic please.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Transform data to tabular format


    I send it to a kid Excel / VBA beginner as a training, he answered back with a working solution few minutes later
    just with the basics - without an advanced filter - as far your need can be understood
    so according to your attachment it can be done without any Dictionary, try this way …

    With my idea to directly create the first column just with an easy advanced filter
    so the row # is well known then you just need to manage the headers.

    For further help attach a sample without any error or you misexplained your need
    as the result in your actual attachment does to not match your explanation.

    If I doubt, I won't waste time to code anything …

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    Can you show me the kid's solution ...?
    I have reattached the sample again at the first post ..
    Last edited by YasserKhalil; 05-01-2020 at 02:27 PM.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Transform data to tabular format


    Remove Option Explicit from the module as its VBA procedure has not any Dim codeline …

    As obviously you can use an advanced filter to directly create the first column
    and use the MATCH worksheet function to check the vertical headers
    and the Range.Find method to scan the horizontal headers …

    PHP Code: 
    Sub Macro1()
        
    Range("E1").Select
        Selection
    .CurrentRegion.Clear
        Range
    ("A1").Select
        Selection
    .Copy
        Range
    ("E1").Select
        ActiveSheet
    .Paste
        LIGNE 
    2
        
    While Range("A" LIGNE) <> ""
        
    VERTI 2
        
    Do While Range("E" VERTI) <> ""
        
    If Range("E" VERTI) = Range("A" LIGNEThen Exit Do
        
    VERTI VERTI 1
        Loop
        
    If Range("E" VERTI) = "" Then
        Range
    ("A" LIGNE).Select
        Selection
    .Copy
        Range
    ("E" VERTI).Select
        ActiveSheet
    .Paste
        End 
    If
        
    HORIZ 6
        
    Do While Cells(1HORIZ) <> ""
        
    If Cells(1HORIZ) = Range("B" LIGNEThen
        
    If Cells(VERTIHORIZ) = "" Then Exit Do
        
    End If
        
    HORIZ HORIZ 1
        Loop
        
    If Cells(1HORIZ) = "" Then
        Range
    ("B" LIGNE).Select
        Selection
    .Copy
        Cells
    (1HORIZ).Select
        ActiveSheet
    .Paste
        End 
    If
        
    Range("C" LIGNE).Select
        Selection
    .Copy
        Cells
    (VERTIHORIZ).Select
        ActiveSheet
    .Paste
        LIGNE 
    LIGNE 1
        Wend
        Application
    .CutCopyMode False
    End Sub 

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    Thanks a lot anyway .. The real problem is that the original data is too large so copying and pasting the data in that approach would be very very slow ..

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Transform data to tabular format


    Not so long just desactivating the screen updating and playing directly with objects as always,
    and just using Excel features as described in my previous post.
    You can also calculate how many rows and how many columns are necessary in order to create an array accordingly …

    Or first think about a logic on paper and once valid then you can elaborate it here.

    I wanna know why you try to use a Dictionary without allocating any data,
    if only there is a logic behind - explain it - as maybe I could see a green light rather than a red one …
    If it's only for the first column so the Dictionary is useless as an advanced filter can create it just with a single codeline !

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    how many columns are necessary in order to create an array accordingly
    I am stuck at this point at the first place. The headers would be dynamic and can be repeated so I can't define the number of columns needed for the array.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Transform data to tabular format

    The real problem is that the original data is too large so copying and pasting the data in that approach would be very very slow
    Lets go back to basics first to understand...And then re-code with arrays...

    Perhaps you are able to upload a sample file with a larger dataset...

    Please Login or Register  to view this content.
    Last edited by sintek; 05-02-2020 at 05:34 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transform data to tabular format

    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    Thank you very much. That's great Sintek

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    That's amazing Jindon
    Thank you very much. That what I was searching for. It is too fast for me
    I will study it carefully to try to learn although I know this is somewhat beyond my mind but I will try to do my best to get each line in the code
    Best and Kind Regards for all of you

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    The logic to apply is the same than the kid's code …
    If you have some difficulty with the Dictionary you could use a Collection which is faster for huge data (around 500k items and more).

    You forgot the more important information in your initial post about the source data size !
    Next time be accurate when creating a thread, the better explanation & attachment, the quicker & more targeted answer …
    Last edited by Marc L; 05-02-2020 at 11:31 AM. Reason: typo …

  16. #16
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Transform data to tabular format

    OK my tutor. Thank you very much for great help.

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Transform data to tabular format


    Before to write any codeline, a paper, a pencil are your best friends.
    If you are stuck in a way and in a hurry, just think about what Excel offers …

    As it depends on the real workbook size
    - difficult to imagine without any information neither an attachment reflecting it in the initial post -
    my first idea is an advanced filter to create the first column just with a single codeline
    - like any Excel beginner operating manually - and an array to allocate the next columns

+ 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. VB Code to convert sheet data into tabular format
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2019, 09:05 PM
  2. Import Json data in Excel in a tabular format
    By sabha in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-17-2019, 03:15 PM
  3. [SOLVED] Formula to reorganzie data in tabular format
    By rizmomin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-20-2018, 01:39 PM
  4. [SOLVED] Macro to Format Store Data in a Tabular Format
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2015, 04:38 AM
  5. Transpose data into a tabular format
    By fausto1234 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2012, 02:04 AM
  6. [SOLVED] Transform user entry data to a more tabular form
    By gcoug in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2012, 01:35 PM
  7. How to Convert Matrix format data into tabular format data
    By nishchints in forum Excel General
    Replies: 1
    Last Post: 02-22-2012, 03:53 PM

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