Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have a table of quarterly shipments by vendor/product and want to convert
this to a pivot table. Right now I have 12 quaters of data, with includes 8 quaters of actual data and 4 of estimates. If I get how pivot tables work, I would need to add 12 rows for each vendor-product combination and have one column that includes "data." Is there an automated way to convert an excel table, where data is in multiple columns, into a pivot table? And then update each quarter. Please tell me if I am going about this the wrong way. I have only used, never set up, pivot tables, Ellen |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Ellen,
Select one cell in your cross-tab data table, and run the macro below. It will create a new sheet with a database table suitable for use with pivot tables. HTH, Bernie MS Excel MVP Sub MakeTable2() Dim myCell As Range Dim newSheet As Worksheet Dim mySheet As Worksheet Dim i As Long Dim j As Integer Dim k As Long Dim l As Integer Dim mySelection As Range Dim RowFields As Integer Set mySheet = ActiveSheet Set mySelection = ActiveCell.CurrentRegion RowFields = Application.InputBox( _ "How many left-most columns to treat as row fields?", _ "CrossTab to DataBase Helper", 1, , , , , 1) On Error Resume Next Application.DisplayAlerts = False Worksheets("New Database").Delete Application.DisplayAlerts = True Set newSheet = Worksheets.Add newSheet.Name = "New Database" mySheet.Activate i = 1 For j = mySelection(1).Row + 1 To _ mySelection(mySelection.Cells.Count).Row For k = mySelection(1).Column + RowFields To _ mySelection(mySelection.Cells.Count).Column If mySheet.Cells(j, k).Value < "" Then For l = 1 To RowFields newSheet.Cells(i, l).Value = _ Cells(j, mySelection(l).Column).Value Next l newSheet.Cells(i, RowFields + 1).Value = _ Cells(mySelection(1).Row, k).Value newSheet.Cells(i, RowFields + 2).Value = _ Cells(j, k).Value i = i + 1 End If Next k Next j End Sub "Pivot Table Creation Help" <Pivot Table Creation wrote in message ... I have a table of quarterly shipments by vendor/product and want to convert this to a pivot table. Right now I have 12 quaters of data, with includes 8 quaters of actual data and 4 of estimates. If I get how pivot tables work, I would need to add 12 rows for each vendor-product combination and have one column that includes "data." Is there an automated way to convert an excel table, where data is in multiple columns, into a pivot table? And then update each quarter. Please tell me if I am going about this the wrong way. I have only used, never set up, pivot tables, Ellen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
pivot table sort entries that don't yet appear in table | Excel Discussion (Misc queries) | |||
Excel Pivot Table Question | Excel Discussion (Misc queries) | |||
Pivot Table Enhancements/Fixes in Excel 2003 | Excel Discussion (Misc queries) | |||
How can deleted data reappear in a refreshed pivot table in Excel | Excel Discussion (Misc queries) | |||
create space in line chart between points, linked to pivot table | Charts and Charting in Excel |