ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SQL code pivotting (https://www.excelbanter.com/excel-programming/425867-sql-code-pivotting.html)

lab-guy

SQL code pivotting
 

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

MSweetG222

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



All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com