Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default create macro - pivot table Select all rows/cols with data less las

I have the following information in an Excel Spreadsheet Office 2000.

The data consists of 11 columns and is updated once a week and the rows can
increase or decrease depending on what Order Date is selected. The
information required is Acc., Name, Part No on the left of the pivot table
(ROW) and the Qty in the middle (DATA). The Qty shown should give the Sum of
Qty and not the Count of Qty. Each time when the macro is run, the Pivot
Table gives me the Count of Qty which is a bit frustrating. What I would
like is that when the macro is selected it picks all the data but NOT the
last row of the first column which just shows a square character, (The square
character is always put in the last row of the first column every time the
data is imported.) and then the Pivot table generates the Acc, Name, Part
No,in the (ROW) and Sum of Qty in the (DATA)

Acc Name Part No Des Qty Col E to Col K ,
42606 ZOL 4140 Assy 25
42004 SAT 4790 Button 150
41930 SAI 5120 Handle 300
42004 SAT 5120 Handle 600
42004 SAT 5155 Exterior 100
41911 TOM 5645 Locker 100
41930 SAI 7140 Lock 200
42004 SAT 7140 Lock 150
41917 CAT 7150 Interior 60
41917 CAT 7155 Interior 40
42004 SAT 7273 Clamp 2000
I have recorded the macro as follows:

Sub PivotTable()

Range("A1").Select
Selection.End(xlToRight).Select
Selection.End(xlDown).Select
Range(Selection, Cells(1)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"AccNoSaleHi1!R1C1:R9999C11").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("Acc
No", "Acc Name", "Part No")
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Qty").Orientation =
xlDataField

End Sub

Would appreciate if someone could help me.
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default create macro - pivot table Select all rows/cols with data lesslas

You could base the pivot table on a dynamic range, then just refresh it
when the data changes, instead of rebuilding. There are instructions he

http://www.contextures.com/xlPivot01.html

Change the formula so it subtracts 1 from the count in column A, e.g.:

=OFFSET(Data!$A$1,0,0,COUNTA(Data!$A:$A)-1,7)

to eliminate the row that contains only the square character.


Johnny wrote:
I have the following information in an Excel Spreadsheet Office 2000.

The data consists of 11 columns and is updated once a week and the rows can
increase or decrease depending on what Order Date is selected. The
information required is Acc., Name, Part No on the left of the pivot table
(ROW) and the Qty in the middle (DATA). The Qty shown should give the Sum of
Qty and not the Count of Qty. Each time when the macro is run, the Pivot
Table gives me the Count of Qty which is a bit frustrating. What I would
like is that when the macro is selected it picks all the data but NOT the
last row of the first column which just shows a square character, (The square
character is always put in the last row of the first column every time the
data is imported.) and then the Pivot table generates the Acc, Name, Part
No,in the (ROW) and Sum of Qty in the (DATA)

Acc Name Part No Des Qty Col E to Col K ,
42606 ZOL 4140 Assy 25
42004 SAT 4790 Button 150
41930 SAI 5120 Handle 300
42004 SAT 5120 Handle 600
42004 SAT 5155 Exterior 100
41911 TOM 5645 Locker 100
41930 SAI 7140 Lock 200
42004 SAT 7140 Lock 150
41917 CAT 7150 Interior 60
41917 CAT 7155 Interior 40
42004 SAT 7273 Clamp 2000
I have recorded the macro as follows:

Sub PivotTable()

Range("A1").Select
Selection.End(xlToRight).Select
Selection.End(xlDown).Select
Range(Selection, Cells(1)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"AccNoSaleHi1!R1C1:R9999C11").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("Acc
No", "Acc Name", "Part No")
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Qty").Orientation =
xlDataField

End Sub

Would appreciate if someone could help me.
Thanks



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

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
Can I transpose data from rows to cols with a formula not pivot ta BrainDead Excel Worksheet Functions 1 June 3rd 10 10:09 PM
Select Subset of Rows/Cols Joe Thompson Excel Discussion (Misc queries) 1 May 19th 10 05:41 AM
Select rows in pivot table with macro Dolphinv4 Excel Discussion (Misc queries) 1 April 22nd 08 06:21 PM
Macro to create pivot table from large data file johnson748r Excel Programming 1 August 9th 06 01:26 AM
Range.Select 1st pass 13 cols, 2nd paqss 25 cols twice as wide in error? Craigm[_53_] Excel Programming 2 May 2nd 06 11:04 AM


All times are GMT +1. The time now is 02:57 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"