+ Reply to Thread
Results 1 to 6 of 6

Macro to fill a table in a certain format

  1. #1
    Registered User
    Join Date
    05-15-2016
    Location
    Turkey
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Macro to fill a table in a certain format

    Hello,

    I would like to ask you about how to type a code which will work just like someone sorting, filtering certain info and then pasting it to a table with a fixed format. For example let the table below be the raw data we have:

    Year Month Product Type Transaction Type Quantity Unit Value in Dollars
    2011 1 A Production 500 Kg 100
    2012 2 B Production 1000 Kg 100
    2013 4 B Foreign Sales 2000 Kg 300
    2012 5 A Foreign Sales 1000 Kg 400
    2012 6 C Domestic Sales 200 Kg 200
    2010 1 D Domestic Sales 200 Kg 300
    2012 2 E Production 100 Kg 500
    2015 3 F Domestic Sales 5000 Kg 1000


    The macro should return a table like this with the appropriate data are entered:

    2010 2011 2012 2013 2014 2015
    Production $
    Kg
    Domestic Sales $
    Kg
    Foreign Sales $
    Kg

    Please note while the raw data is not chronologically ordered the output table should be so. By the way is it possible for the macro to provide the user with an option to select the time period the user interested in as well as the product type. A message box which asks if the user is interested in one or multiple product types and also if the user wants only a certain period to be taken into consideration. If none of these are the case, then the macro will fill the table for the complete span of the info.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Macro to fill a table in a certain format

    Looking at your data and desired output, probably you do not need a macro, but could use just Pivot Table. Are you familiar with this built-in excel tool?
    Best Regards,

    Kaper

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Macro to fill a table in a certain format

    PS. Have a look at the sample
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-15-2016
    Location
    Turkey
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Re: Macro to fill a table in a certain format

    yes I am familiar with pivot tables but I need that certain data so that another excel sheet uses it for formulas and calculations. in fact with a little handwork a pivot table gets the job done but I am trying to speed things up with as little mistakes as possible.

  5. #5
    Registered User
    Join Date
    05-15-2016
    Location
    Turkey
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Re: Macro to fill a table in a certain format

    Hello and thanks for your reply.

    You are right pivot tables come real handy for such tasks but I need that certain information extracted from the raw data so that it can directly go into a report easily and more accurately.
    Can you help me with that?

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Macro to fill a table in a certain format

    I really see no point to do this from the scratch, while pivot table has it all.
    Of course one can built a kind of "Pivot Table Director" - for instance in UserForm and select period, products, etc in it. But then, IMO, easiest and most accurate way is still to produce pivot table out of raw data just using this userform content to filter output.

+ 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. Create or fill a table, without VBA Macro ?
    By KomicJ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-19-2016, 01:16 PM
  2. Macro to fill up a table with formulas
    By aadeshgandhi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2013, 05:25 PM
  3. Macro to draw a table and fill its cells
    By LLang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 11:38 AM
  4. Macro to Fill down and across a table, using table references.
    By irishman311 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 07:36 PM
  5. Macro to fill a table with data
    By akaponem in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2012, 03:28 AM
  6. Using Macro to Fill in Table
    By RJ138 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2010, 01:19 PM
  7. Pivot table to launch Macro- preserve format under table options
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2005, 02:05 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