Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great!
One last question, I tried to carry on this concept further but I fail at the wk in this example Again thanks so much for you time! Sub Pivot() ' ' Pivot Macro ' ' Dim wk As Worksheet Set wk = ActiveSheet Cells.Select Range("B1").Activate Sheets.Add ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase, SourceData:= _ "wk!R1C1:R1048576C14", Version:= _ xlPivotTableVersion12).CreatePivotTable TableDestination:="Sheet1!R3C1", _ TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12 Sheets("Sheet1").Select Cells(3, 1).Select With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Category") .Orientation = xlPageField .Position = 1 End With With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Src Host") .Orientation = xlRowField .Position = 1 End With ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _ "PivotTable1").PivotFields("Src Host"), "Count of Src Host", xlCount With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Dest Host") .Orientation = xlRowField .Position = 2 End With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Src Host").AutoSort _ xlDescending, "Count of Src Host" Range("A5").Select ActiveSheet.PivotTables("PivotTable1").PivotFields ("Dest Host").AutoSort _ xlAscending, "Dest Host" ActiveSheet.PivotTables("PivotTable1").PivotFields ("Src Host").ShowDetail = _ False End Sub "JE McGimpsey" wrote: Better: Dim Wk As Worksheet Set Wk = ActiveSheet Wk.Sort.SortFields.Add _ Key:=Wk.Range("B1"), _ SortOn:=xlSortOnValues, _ Order:=xlAscending, _ DataOption:=xlSortNormal In article , JE McGimpsey wrote: In this case, Dim Wk As Worksheet Set Wk = ActiveSheet Wk.Sort.SortFields.Add _ Key:=Range("B1"), _ SortOn:=xlSortOnValues, _ Order:=xlAscending, _ DataOption:=xlSortNormal |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do you get a macro to reference the worksheet it is being run | Excel Discussion (Misc queries) | |||
Newbie Cell Reference Question... | New Users to Excel | |||
Newbie vba - How do I reference cells in another workbook | Excel Programming | |||
Newbie help with cell reference | Excel Programming | |||
Newbie question on cell reference 2 | Excel Programming |