C
childofthe1980s
Hello:
Could someone please review my code and the thread below and give me some
options? The thread is on the second or third page of this message baord
already, and I fear that it is getting ignored.
Hi:
My code is below. As far as what it accomplishes, please review toward the
end. I am copying three sets of formulas into three columns (one formula per
column).
Thanks, for looking at this.
Sub Consolidated()
'
' Consolidated Macro
' Macro recorded 4/21/2008 by John Ellis
'
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R1864C12").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Item Number")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Qty On Hand"), "Sum of Qty On Hand", xlSum
Range("B5").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of Qty On
Hand"). _
Function = xlAverage
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Columns("F:I").Select
Selection.Delete Shift:=xlToLeft
Range("G1").Select
ActiveCell.FormulaR1C1 = "Past Due"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Due This Week"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Due in the Future"
Columns("I:I").Select
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Range("G2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<TODAY(), RC[-3], 0)"
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-2]>TODAY(), RC[-2]<TODAY()+7), RC[-4], 0)"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TODAY(), RC[-5], 0)"
Range("G2:I2").Select
Selection.Copy
Range("G3:I1864").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(7, 8,
9), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub
childofthe1980s
Could someone please review my code and the thread below and give me some
options? The thread is on the second or third page of this message baord
already, and I fear that it is getting ignored.
Hi:
My code is below. As far as what it accomplishes, please review toward the
end. I am copying three sets of formulas into three columns (one formula per
column).
Thanks, for looking at this.
Sub Consolidated()
'
' Consolidated Macro
' Macro recorded 4/21/2008 by John Ellis
'
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R1864C12").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Item Number")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Qty On Hand"), "Sum of Qty On Hand", xlSum
Range("B5").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of Qty On
Hand"). _
Function = xlAverage
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Columns("F:I").Select
Selection.Delete Shift:=xlToLeft
Range("G1").Select
ActiveCell.FormulaR1C1 = "Past Due"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Due This Week"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Due in the Future"
Columns("I:I").Select
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Range("G2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<TODAY(), RC[-3], 0)"
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-2]>TODAY(), RC[-2]<TODAY()+7), RC[-4], 0)"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TODAY(), RC[-5], 0)"
Range("G2:I2").Select
Selection.Copy
Range("G3:I1864").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(7, 8,
9), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub
childofthe1980s