View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MSweetG222 MSweetG222 is offline
external usenet poster
 
Posts: 158
Default SQL code pivotting

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").Source Data
sSQLTxt = sSQL(2)
Msgbox sSQLTxt

Hope that helps. :)

--
Thx
MSweetG222



"lab-guy" wrote:


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