I have 40 Excel Workbooks each with 25 Worksheets containing data in columns A:Q and variable number of rows (would be less than 5000 rows).

Each of the 40 Workbooks represents 1 Team. Each of the 25 Worksheets is 1 month's worth of data and the sheets are named 'Jan-15', 'Feb-15' etc... to 'Dec-16', so obviously only 5 sheets have data within them so far (as it is now May-15). Each workbook is set up for future data.

I need to get all the data into one place, which I thought would be best to use a pivot table. So far, I have set up an additional workbook that contains VBA code to pull the required data into one Pivot table. It does this by having checkboxes on a Sheet for each team and more checkboxes for each month. If the checkbox is checked (= TRUE), then the data for that team and month will be pulled through.

E.g. If 'Team 1' and 'Jan-15' is selected, the pivot table will show Team 1's January data. If 'Team 5' and 'Mar-15' is selected, then Team 1 and Team 5's Jan and March data will be pulled through.

Is does this in VBA by compiling an SQL string of the required data (my SQL knowledge is limited to 2 days' research!), such as:

```
SELECT * 
  FROM `Team 13.xlsx`.[JAN-15$] 
UNION ALL 
SELECT * 
  FROM `Team 13.xlsx`.[FEB-15$] 
UNION ALL 
SELECT * 
  FROM `Team 13.xlsx`.[MAR-15$] 
UNION ALL 
SELECT * 
  FROM `Team 15.xlsx`.[JAN-15$] 
UNION ALL 
SELECT * 
  FROM `Team 15.xlsx`.[FEB-15$] 
UNION ALL 
SELECT * 
  FROM `Team 15.xlsx`.[MAR-15$]"  
   etc....

```

Sometimes I will only need to see, say Team 3's data for Jan-15 and Feb-15, sometimes I'll need Teams 1 to 10's data for Mar-15 and sometimes I'll need to see all 40 Teams' data over the last 12 months.

However, I am struggling now, because this only works for a certain number of selections. I only need to select up to 12 months at a time, so I have limited the number of 'month' checkboxes that can be selected, but I can't select all 40 of the Teams and all 12 months as I get an error message that says 

> 
> Run-time error '1004': [Microsoft][ODBC Excel Driver] Query is too complex. 
> 
> 
> 

If I only select 10 Teams and 5 Months, or 40 Teams and 1 Month, the Query runs fine, but I need more.

Is my SQL code wrong, or is there a better way to write it?

Or is there another way that I can combine all this data? (I only have Excel, not Access, at my disposal!)