LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default excel macro

1. copies 3 spreadsheet columns
2. pastes into new workbook
3. insets 2 columns and creates month value from date in col.A
4. selects the active range in columns C, D, E and creates 2 pivot
tables
It fails in the pivot table operation. Also should be more efficient
by using the range twice for the 2 pivot tables.

' Macro recorded 9/27/2004 by lander11
'
ActiveWindow.LargeScroll ToRight:=1
Range("L:L,S:S,U:U").Select
Range("U1").Activate
Selection.Copy
Workbooks.Add Template:="Workbook"
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("B4").Select
Application.CutCopyMode = False
' insert 2 columns
Selection.EntireColumn.Insert
Selection.EntireColumn.Insert
Range("D4").Select
Dim lastRow As Long
lastRow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
Range("C4").Select
ActiveCell.FormulaR1C1 = "mon"
Range("C5").Select
ActiveCell.FormulaR1C1 = "=MONTH(RC[-2])"
Range("C5").Select
Selection.AutoFill Destination:=Range("C5:C" & lastRow)
' column C only
Dim xyz As Range
Range("C4").Select
Intersect(ActiveCell.CurrentRegion,
ActiveCell.EntireColumn).Select
Selection.Offset(0, 0).Resize(Selection.Rows.Count,
Selection.Columns.Count + 2).Select
Selection.Name = "xyz"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=xyz).CreatePivotTable TableDestination:="", _
TableName:="PivotTable5" ' DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable5").SmallGrid = False
ActiveSheet.PivotTables("PivotTable5").AddFields
RowFields:="CUST_CONC_CD", _
ColumnFields:="mon"
With ActiveSheet.PivotTables("PivotTable5").PivotFields ("mon")
.Orientation = xlDataField
.Caption = "Count of mon"
.Function = xlCount
End With
Sheets("Sheet1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Sheet1!R4C3:R999C5").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable6"
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable6").SmallGrid = False
ActiveSheet.PivotTables("PivotTable6").AddFields RowFields:= _
"PART_NUM_CAUS_BASE", ColumnFields:="mon"
With ActiveSheet.PivotTables("PivotTable6").PivotFields ("mon")
.Orientation = xlDataField
.Caption = "Count of mon"
.Function = xlCount
End With
End Sub
 
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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


All times are GMT +1. The time now is 01:55 PM.

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"