Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Programming a pivot

I receive a mass of data from an external program, which I paste into
Excel and then run a macro against to clean up and create a couple of
pivots out of. The problem I am having is that when I create my
pivots, the data is lined up in rows under the column fields, instead
of in columns alongside them. I have cobbled together a "move" of the
data to get it into the correct format, but this is not a very elegant
solution and, with the volumes increasing, not practical long term.
Can anyone point out where I am going wrong as I have tried changing
the "Orientation = xlDataField" to "Orientation = xlColumnField" to no
avail.

the data format is as follows
Column
A Proj#
B Lvl1
C Lvl2
D Lvl3
E Lvl4
F Region
G Lvl6
H Region/Country
I Business or IT
J Project
K Phase/Task
L Resource
M Team
N Team Leader
O Director
P-AA Monthly (Jan-Dec) forecast of requirements in days

the code I am using at present to create the Pivot is as follows

Sheets("Project Data").Select
EndData = Range("A" & Rows.Count).End(xlUp).Row
Sheets("Forecast by Team").Visible = True
Sheets("Forecast by Team").Select
Columns("A:AE").Select
Selection.Delete Shift:=xlToLeft
wbname = ActiveWorkbook.Name

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"'Project data'!R1C1:R" & EndData & "C27").CreatePivotTable
TableDestination:= _
"'[" & wbname & "]Forecast by Team'!R1C1", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1").PivotFields
("WorkID").Subtotals = Array( _
False, False, False, False, False, False, False, False, False,
False, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Phase/
Task").Subtotals = _
Array(False, False, False, False, False, False, False, False,
False, False, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields
("Resource").Subtotals = _
Array(False, False, False, False, False, False, False, False,
False, False, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Team
Leader").Subtotals = _
Array(False, False, False, False, False, False, False, False,
False, False, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields
("Director").Subtotals = _
Array(False, False, False, False, False, False, False, False,
False, False, False, False)
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array
("Director", _
"Team Leader", "Team", "Project", "Phase/Task", "Resource",
"WorkID", "Data")

For M = 1 To 12
With ActiveSheet.PivotTables("PivotTable1").PivotFields
(ColMonth(M))
.Orientation = xlDataField
.Caption = ColMonth(M) & " "
.Position = M
.NumberFormat = "0.00"
End With
Next

ActiveWorkbook.ShowPivotTableFieldList = True
Range("H1").Select
With ActiveSheet.PivotTables("PivotTable1").DataPivotFi eld
.Orientation = xlColumnField
.Position = 1
End With
ActiveWorkbook.ShowPivotTableFieldList = False

Any help much appreciated
Thanks and regards
Fred
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 Programming Té Excel Programming 3 April 9th 09 12:39 AM
Programming a pivot table Jim Excel Programming 5 September 20th 07 06:13 PM
Pivot Table Programming (Selecting Pivot Items) Manish Jaitly[_2_] Excel Programming 0 May 30th 07 10:51 AM
Pivot table programming havocdragon Excel Programming 1 September 14th 06 02:57 PM
Pivot table Programming Kris Excel Programming 1 October 5th 04 09:03 PM


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