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: 121
Default Macro1

Presently I have the following code.

Sub Macro1()
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="11"
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets.Add
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "11"
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Sheet1").Select
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter Field:=2, Criteria1:="12"
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "12"
Range("A1").Select
Sheets("Sheet1").Select
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter Field:=2, Criteria1:="01"
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "01"
Range("A1").Select
Sheets("11").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'11'!R1C1:R427C12").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:="Order
type", _
ColumnFields:="Created on"

ActiveSheet.PivotTables("PivotTable2").PivotFields ("Material").Orientation = _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = True
Sheets("Sheet5").Select
Sheets("Sheet5").Name = "Pivot Table - 11"
Range("A1").Select
End Sub



My only problem is that this code does not work all the time. I am trying
to create a code that will perform the following functions, all the time.

Copy every row that has an 11 in Column B2:B800.

Open a new worksheet (Sheet 2) and make A1:L1 Sheet 2 the same as A1:L1 in
Sheet 1.

Paste all the rows that had an 11 in Column B into Sheet 2, starting at cell
A2.

Rename Sheet 2 11.

Return to Sheet 1.

Copy every row that has a 12 in Column B2:B800.

Open a new worksheet (Sheet 3) and make A1:L1 Sheet 3 the same as A1:L1 in
Sheet 1.

Paste all the rows that had a 12 in Column B into Sheet 2, starting at cell
A2.

Rename Sheet 3 12.

Return to Sheet 1.

Copy every row that has a 01 in Column B2:B800.

Open a new worksheet (Sheet 4) and make A1:L1 Sheet 4 the same as A1:L1 in
Sheet 1.

Paste all the rows that had a 01 in Column B into Sheet 2, starting at cell
A2.

Rename Sheet 4 01.

Go to Sheet 11 Cell A1.

Data

Pivot Table & Pivot Chart Wizard

Next

Next

Layout

Place Created On into Column field.

Place Order Type into Row Field.

Place Material into Data Field.

Ok

Finish. Put the Pivot Table into a New Worksheet.

Rename New Worksheet Pivot Table 11.


What do you think?
WB
 
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
If sheet name contains 'A' run macro1, if 'B' run macro 2? Dr Dan[_2_] Excel Discussion (Misc queries) 6 February 23rd 07 05:18 PM
Delete Unwanted Macro1 Sheet keithb Excel Programming 0 September 8th 05 06:55 PM
Need Macro1 to call Macro2 stored on Network drive LESman Excel Programming 2 June 9th 05 10:49 PM
inputbox and application.run macro1 Michael Joe Excel Programming 3 August 13th 04 09:34 PM
Activate macro1 IRMA MENDOSA Excel Programming 2 April 17th 04 09:25 AM


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