+ Reply to Thread
Results 1 to 9 of 9

Create a Table from data set

  1. #1
    Registered User
    Join Date
    09-11-2014
    Location
    San Francisco, CA
    MS-Off Ver
    2013
    Posts
    24

    Create a Table from data set

    Hello,

    I compile a routine report from the data in the attached spreadsheet. I’m hoping to write some code to streamline this process.

    In the attached workbook, there are three spreadsheets.

    (1) In the first spreadsheet “Before” is the data I receive.

    (2) In the “After” spreadsheet, I removed the Event/Date Time, Last Name, First Name columns, and totaled the number of times each FC4 code was counted in the “Before” spreadsheet. (I use 'subtotal' count, and then only leave the 'total' line for the subtotal, and delete other entries)

    (3) I then use the “After" spreadsheet to create a Pivot Table (the final spreadsheet). That reports the City (Column A) as the Row Label, Count of FC4 (Column B) and Sum of Number (Column C).

    I do not know if Pivot Tables can be commanded from VBA but if its, possible that would be ideal!
    Any ideas to help streamline this process would be appreciated as going from the “Before” to “After” is quite a few steps (counting using subtotals, then removing rows that don’t include that count, then cutting out columns).

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create a Table from data set

    Well. Not pretty, but this macro should automate the data to the state where you can perform the pivot table. I used a helper column to do the Sum on the pivot table just an FYI.

    PS: Copy your data to the Worksheet named "In" first before run the macro.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-11-2014
    Location
    San Francisco, CA
    MS-Off Ver
    2013
    Posts
    24

    Re: Create a Table from data set

    Hi JieJenn,

    The code is deleting the columns A,B,C and duplicate entries well.

    However, the Helper Column is full of '0's (instead of the subtotal counts) when I run the code. Any ideas on this?

    Thank you for your help!

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create a Table from data set

    Did you copy your raw data to the "In" tab first? Basically what I did was based on your bullet #2, except I use SumIF to sum the total first then remove the dupes.

    (2) In the “After” spreadsheet, I removed the Event/Date Time, Last Name, First Name columns, and totaled the number of times each FC4 code was counted in the “Before” spreadsheet. (I use 'subtotal' count, and then only leave the 'total' line for the subtotal, and delete other entries)

  5. #5
    Registered User
    Join Date
    09-11-2014
    Location
    San Francisco, CA
    MS-Off Ver
    2013
    Posts
    24

    Re: Create a Table from data set

    I copied the data into the 'In' spreadsheet first and then ran the code. The 'helper column' is all zeros though. Hmmm...

    Thank you!

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create a Table from data set

    Can you attach your file?

  7. #7
    Registered User
    Join Date
    09-11-2014
    Location
    San Francisco, CA
    MS-Off Ver
    2013
    Posts
    24

    Re: Create a Table from data set

    Attached is the latest workbook, with the Helper Column with 0's.

    Thanks.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Create a Table from data set

    Oh. Didn't realize your column E was formatted as Text. Here, try

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-11-2014
    Location
    San Francisco, CA
    MS-Off Ver
    2013
    Posts
    24

    Re: Create a Table from data set

    Great! It is working and all of the counts are being totaled in the helper column. Thank you.

    Now, I will just have to create the pivot table. (Unless you know of a way to command the pivot table with code?)

    Thank you so much, this is a huge improvement!

+ 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. Replies: 0
    Last Post: 01-19-2015, 11:00 AM
  2. Replies: 3
    Last Post: 04-15-2009, 11:50 PM
  3. Replies: 0
    Last Post: 12-04-2008, 06:59 AM
  4. how to create a table given data...
    By aidenkun via OfficeKB.com in forum Excel General
    Replies: 2
    Last Post: 07-11-2005, 03:05 PM
  5. [SOLVED] How do I create a one variable data table?
    By Prelll91 in forum Excel General
    Replies: 1
    Last Post: 02-27-2005, 04:06 PM

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