#1   Report Post  
Posted to microsoft.public.excel.misc
anu anu is offline
external usenet poster
 
Posts: 18
Default macro for a pivot

Hi,

I want a macro for creating a pivot table.
Pivot table has one row field, one column field and one data field (where I
want a count of data). After this I want to rename the pivot table new sheet.
However it give me an error called "subscript out of range" & "Run time
error 9".
Can any one please help me with this?

Many Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default macro for a pivot

You can record a macro as you create the pivot table and then assign the
macro to a button for future use.

"anu" wrote:

Hi,

I want a macro for creating a pivot table.
Pivot table has one row field, one column field and one data field (where I
want a count of data). After this I want to rename the pivot table new sheet.
However it give me an error called "subscript out of range" & "Run time
error 9".
Can any one please help me with this?

Many Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
anu anu is offline
external usenet poster
 
Posts: 18
Default macro for a pivot

I tried this. It works well till the time pivot tabel is created. But as soon
as I try to rename the sheet I get an error. After when I try to rename the
pivot table sheet I get error as mentioned below.Find below the command set
which I used.

Sheets("Final Sheet").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Final Sheet'!R1C1:R1567C43").CreatePivotTable
TableDestination:="", _
TableName:="PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("CODE")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataFiel d
ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Type"), "Count of Type", xlCount
Range("A3").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields ("Count of Type"). _
Orientation = xlHidden
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Type")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataFiel d
ActiveSheet.PivotTables
("PivotTable2").PivotFields("CTRY"), "Count of CTRY", xlCount

' HERE I GET AN ERROR IN THE LINE BELOW'
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Pre Checks"
Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

Sheets("CHECKS").Select
Range("A2").Select
ActiveSheet.Paste



"Dave F" wrote:

You can record a macro as you create the pivot table and then assign the
macro to a button for future use.

"anu" wrote:

Hi,

I want a macro for creating a pivot table.
Pivot table has one row field, one column field and one data field (where I
want a count of data). After this I want to rename the pivot table new sheet.
However it give me an error called "subscript out of range" & "Run time
error 9".
Can any one please help me with this?

Many Thanks

Reply
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
Pivot Table external XLS file source change and GETPIVOTDATA refresh mbobro Excel Discussion (Misc queries) 0 July 8th 06 12:45 PM
pivot tables macro Hru48 Excel Discussion (Misc queries) 14 July 6th 06 04:25 PM
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Macro to Modify Pivot Table for Color and Bold Cheryl B. Excel Worksheet Functions 1 July 7th 05 03:52 PM
Macro for Pivot Tables Thomas Excel Discussion (Misc queries) 1 March 15th 05 01:03 AM


All times are GMT +1. The time now is 01:03 PM.

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"