LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Pivot Tables and VBA

Hi All

I do a lot of Excel Query SQL DB bits and bobs and because of the
complexity of my latest report I need to put this data into a pivot table.
I want to make it as auto as possible so the way I want to do it is as
follows:

Worksheet 1 (called "Enter Date Range") asks the user to enter a start date
in cell B1 and an end date in cell B2 before clicking a simple form button.

This form button executes the following Macro code module:

With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExter nal)
.Connection = _
"ODBC;DSN=SQL;UID=rob;PWD=;WSID=Me;DATABASE=Accoun ts;AutoTranslate=No;UsePro
cForPrepare=0"
.CommandType = xlCmdSql
.CommandText = Array( <<< my SQL DB query incoprating my start and
end at values from the first worksheet )
.CreatePivotTable TableDestination:="", TableName:="PivotTable1"
End With
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("NAME")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("NAME2")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("QUANTITY")
.Orientation = xlDataField
.Position = 1
End With

Although the above generates the required report, my problems are as
follows:

1) It keeps putting the above pivot table into a new worksheet everytime. I
want it to go to one specific worksheet called "Report" and when the user
goes back and enters a new date range (on the "Enter Date Range" worksheet)
I want it to simply execute and use the same "Report" worksheet to display
the new pivot report data without creating orphaned resources. Any ideas on
how to do this?

2) I'm using Excel 2000 on a PC and annoyance no. 1 is that every time the
above creates the pivot table it shows the Pivot toolbar with the extended
grey bottom bit showing the extra fields (the Display/Hide Fields button at
the far right toggles the display of this). When this is displayed it also
mucks about with the display of the report, eg blue borders and things. I
don't want any of this can the toolbar be stopped from doing this?

3) Major annoyance no.2 why the hell can't I remove the grey data field
boxes from the top of my pivot report???? It makes the report look crap and
if I click on them and select the Hide option it loses my data. The
unsightly options I am talking about are as follows:

<Sum of of a Field <Drop Down menu of a Field
<Drop Down menu of a Field my data my data
my data my data my data
my data my data my data

I'm talking about the 3 encapsulated in the <'s.

An end user will always click on these and cock the report up, any ideas on
how to hide these successfully without losing the data???

Many thanks.

Laphan


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building pivot tables in Excel 2007 based on existing pivot tables? [email protected] Excel Discussion (Misc queries) 4 December 26th 07 08:05 PM
Pivot Table Data Adding contents of two pivot tables and param que Roundy Excel Discussion (Misc queries) 0 July 2nd 07 10:20 PM
Average Calculations from Pivot Tables - Get Pivot Data? Calc Fiel westy Excel Worksheet Functions 5 March 10th 07 01:31 AM
How does the term 'pivot' apply to Excel's Pivot tables and Pivot. stvermont Excel Discussion (Misc queries) 1 February 17th 05 01:34 AM
Pivot tables-controlling user interaction with pivot tables Sindhura Excel Programming 0 August 27th 03 02:10 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"