+ Reply to Thread
Results 1 to 4 of 4

VBA To Create Multiple Queries When Data Varies

  1. #1
    Forum Contributor
    Join Date
    12-28-2015
    Location
    US
    MS-Off Ver
    365
    Posts
    133

    VBA To Create Multiple Queries When Data Varies

    Hi All,

    I have a database and I need to be able to separate data the same way each time, but the data is always different. I have attached a sample spreadsheet as an example. Basically, I'll have the "Main" tab and then will need to separate the data by Team, By Year and then by State. The way I am accomplishing that now is by manually filtering every single time (terrible!). The Sample file shows what the main data format looks like and then a sample breakdown of TeamA (only), I'll create separate files for TeamB-TeamD and break the data out the same way.

    So ideally, I would like to be able to upload this "Main" data dump to MS Access and with a combo box set to "Team A" and then create all the individual tabs or queries that I make manually by filtering. The thing is that every time I have a new data dump there will always be different numbers of Teams, States and Years. So I think the VBA would have to know to only create tabs/queries where years, teams and states are present and exclude where there are gaps.


    Thanks!!!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,190

    Re: VBA To Create Multiple Queries When Data Varies

    That is a horrible way to store data. Ive had users do this too.
    So what I did was make an XL macro to parse the data sheets. It takes the row blocks and copies it to an 'export' sheet, in the correct db layout.
    This export sheet is linked to the access db as a table. So once the parsing is done, I open the Access db, and run the import macro.
    The macro pulls the xl data into a table where NOW it can be reported.

  3. #3
    Forum Contributor
    Join Date
    12-28-2015
    Location
    US
    MS-Off Ver
    365
    Posts
    133

    Re: VBA To Create Multiple Queries When Data Varies

    I would have no issue with manipulating the data first in XL via a macro. Would you be able to post a recommended macro per the sample data. Keeping mind that the sample data is a fraction of the size the actual file will be. The actual file could have 10 years worth of data, up to 20 different teams and every state and that could be 20,30 or 50+ tabs in XL.

  4. #4
    Forum Contributor
    Join Date
    12-28-2015
    Location
    US
    MS-Off Ver
    365
    Posts
    133

    Re: VBA To Create Multiple Queries When Data Varies

    Can someone possibly help and post a recommended macro??

    Thanks!

+ 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: 05-16-2014, 04:14 PM
  2. VBA to pull to create multiple web queries on 1 worksheet
    By M_J_B in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2011, 02:13 PM
  3. Production planning - retrieve, update data and multiple queries
    By swanseaexcel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-05-2011, 12:06 PM
  4. Pivot Items Count varies on multiple runs
    By narendramaruti in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2009, 07:38 PM
  5. How do I create a macro to run queries with worksheet data
    By jfinn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2006, 07:15 AM
  6. [SOLVED] Create a report using multiple queries
    By bdiff in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-04-2006, 09:15 AM
  7. Replies: 0
    Last Post: 02-13-2006, 06:10 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