+ Reply to Thread
Results 1 to 3 of 3

Macro to build summary table

  1. #1
    Registered User
    Join Date
    04-11-2016
    Location
    London
    MS-Off Ver
    Office Standard 2010
    Posts
    5

    Macro to build summary table

    Hey guys

    I'm trying to write a macro that will cycle through a large data table, and build a summary table from that would work like this:

    Date | B/S | Quant | Price
    14/4 | B | 1 | 1
    14/4 | B | 2 | 2
    14/4 | S | 1 | 4
    14/4 | S | 1 | 1
    14/4 | B | 3 | 1
    15/4 | B | 1 | 1

    Would become:

    Date | B/S | Quant | Price
    14/4 | B | 4 | 1
    14/4 | S | 1 | 1
    14/4 | B | 2 | 2
    14/4 | S | 1 | 4
    15/4 | B | 1 | 1

    Basically I want the total quantity of the same price bought, or sold, on the same day.

    I assume the method would follow something like:
    1. Cycle through the prices, and when a unique price is found, note the b/s, the date and the quantity.
    2. When the same price is found, if the b/s and date are the same, add the quantity. Continue through list. Else Start again, from 1 below.
    4. When for next price, cycle through above prices and if same price found again, move on.
    3. Go until there isnt a value (ie reached end)

    Here is my attempt, first error i get is the "Next i" after the if statement doesnt work. Dont want to use break though as I just want to move on to next i.

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,864

    Re: Macro to build summary table

    Why not just do this in a Pivot Table?

    Capture.PNG
    Last edited by alansidman; 04-19-2016 at 09:53 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    04-11-2016
    Location
    London
    MS-Off Ver
    Office Standard 2010
    Posts
    5

    Re: Macro to build summary table

    Because I need to do this every day, so simply clicking one macro button would be great.

    Also using it as a learning experience

+ 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. Need to build a Macro that can dynamically add rows to a table based on criteria
    By vbanoobz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-05-2014, 06:39 PM
  2. Automating formula to build summary tables
    By Matty5894 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2014, 11:04 AM
  3. How to build a macro with DeleteObject to delete a table.
    By FLCRUCET in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-31-2013, 06:30 PM
  4. [SOLVED] Macro/Code to Go Through Workbook and Build a Summary
    By midnightorion in forum Excel Programming / VBA / Macros
    Replies: 103
    Last Post: 09-18-2012, 07:25 PM
  5. Macro to Build a Pivot Table
    By Staci in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-26-2011, 04:40 PM
  6. Build Summary (top10) from Raw Data - Sort and Filter
    By exc4libur in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-09-2011, 10:27 PM
  7. pivot table build using excel macro
    By jnewl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-16-2006, 08:55 AM

Tags for this Thread

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