Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do you build pivot table in VB

I saved a macro that builds a given pivot table in excel and is shown below. Question is how do I change this so that the "SourceData" range can be given in row number, column number format rather than what's shown

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
"Sheet1!R1C1:R29C20").CreatePivotTable TableDestination:="", TableName:=
"PivotTable1
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1
ActiveSheet.Cells(3, 1).Selec
With ActiveSheet.PivotTables("PivotTable1"
.ColumnGrand = Fals
.RowGrand = Fals
.SmallGrid = Fals
End Wit
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("WMW", "WML"
, "COIL HGT"), ColumnFields:="Run#
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Qty").Orientation =
xlDataFiel
Range("B7").Selec
Selection.Delet
Range("A7").Selec
Selection.Delet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How do you build pivot table in VB

I just set it to my range:

dim myRng as range
with worksheets("sheet1")
set myRng = .range("a1:T" & .cells(.rows.count,"A").end(xlup).row)
end with

later....

....sourcedata:=myrng.address(external:=true).....



Darrell Wesley wrote:

I saved a macro that builds a given pivot table in excel and is shown below. Question is how do I change this so that the "SourceData" range can be given in row number, column number format rather than what's shown.

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet1!R1C1:R29C20").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1")
.ColumnGrand = False
.RowGrand = False
.SmallGrid = False
End With
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("WMW", "WML" _
, "COIL HGT"), ColumnFields:="Run#"
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Qty").Orientation = _
xlDataField
Range("B7").Select
Selection.Delete
Range("A7").Select
Selection.Delete


--

Dave Peterson

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
Help to build a table Mary Excel Discussion (Misc queries) 5 March 5th 10 07:14 PM
Build a Table jxbeeman Excel Discussion (Misc queries) 2 August 12th 09 11:19 PM
Different ways to build Pivot table Jan T.[_3_] Excel Discussion (Misc queries) 1 March 3rd 09 08:46 PM
build a pivot table from multiple other pivot tables. Gordo Excel Discussion (Misc queries) 1 December 11th 06 08:19 PM
How can I build a pivot table from multiple worksheets which are . Richard Stephens Excel Discussion (Misc queries) 2 February 26th 05 10:04 PM


All times are GMT +1. The time now is 04:19 AM.

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

About Us

"It's about Microsoft Excel"