+ Reply to Thread
Results 1 to 5 of 5

Creating table out of columns of data with macro

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Unhappy Creating table out of columns of data with macro

    I have an excel spreadsheet that is in a terrible layout and I need to change it.

    I know I need to convert some columns into rows and copy a number multiple times - because it's hard to explain I've attached part of the document (there are still more colums that are not included).

    See below for a short example of how it looks and how I want it to look:

    Currently it looks like this: (number is in row A - and Date \ Quantity in row B -- only two rows so first number (with the - s is in row A and all the remaining information is in row B)

    Number Date \ Quantity
    02-88616-2046 4-Jul-2011\5000|8-Aug-2011\5000
    02-88479-247 4-Jul-2011\4000|25-Jul-2011\4000|19-Sep-2011\4000|9-Jan-2012 \4500|5-Mar-2012\4500

    I would like for it to look like this (all of the #s with -s in row A -repeating if necessary - all of the QTYs in row B - and all of the dates in row C):

    # QTY Date
    02-88616-2046 5000 07/04/2011
    02-88616-2046 5000 08/08/2011
    02-88479-247 4000 07/04/2011
    02-88479-247 4000 07/25/2011
    02-88479-247 4000 09/19/2011
    02-88479-247 4500 01/09/2012
    02-88479-247 4500 03/05/2012



    and so on....

    I think a macro would be easiest to do this because there's so many columns to do (around 560)


    Please help! I'm totally lost on how to complete this project.

    Thanks!
    Attached Files Attached Files
    Last edited by Jszota; 06-23-2011 at 10:31 AM. Reason: incorrect explaination of what i wanted

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Creating table out of columns of data with macro

    Hello Jzsota,

    Welcome to the Forum!

    The following macro has been added to the attached workbook. This will create the table you described. This macro works with Excel 2000 and up. If you plan to run this on an earlier version of Excel, I will need to make some changes to macro.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Creating table out of columns of data with macro

    Jszota,

    Welcome to the Excel Forum.


    Detach/open workbook CreateTable A B to E F G - Jszota - EF781057 - SDG12.xls and run macro CreateTable.



    If you want to use the macro on another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Then run the CreateTable macro.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Creating table out of columns of data with macro

    Here's another macro

    I have renamed your sheet ".csv]DownloadedData[1]" as "csv DownloadedData(1)"
    Square brackets and dots in sheet names are a bad idea, and can confuse Excel.
    Sheet "csv DownloadedData(BU)" is a backup copy, run the macro on "csv DownloadedData(1)".
    To see it again copy "csv DownloadedData(BU)" and paste over "csv DownloadedData(1)"

    Please Login or Register  to view this content.

    Hope this helps.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    06-21-2011
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating table out of columns of data with macro

    Thank you all SO much for your help. All of the macros worked great - I really could not have done this without you all.

    Thanks again!

+ 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