SQL code pivotting

  • Thread starter Thread starter lab-guy
  • Start date Start date
L

lab-guy

Hello

I've run my own pivot tables before; Find it easier to work with and for
documentation.

How do I handle multiple data ranges, as in Excel's wizard ?
Is there a way to display the SQL for a table excel created ?

Thanks

Mike
 
To retrieve SQL from an external SQL query try...

sSQLTxt = Sheets("Sheet1").QueryTables(1).Sql
Msgbox sSQLTxt

To retrieve SQL from a pivot table using an external SQL query try...

sSQL = Sheets("Sheet1").PivotTables("PivotTable1").SourceData
sSQLTxt = sSQL(2)
Msgbox sSQLTxt

Hope that helps. :)
 
Back
Top