LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Newbie, I dont want macro to reference worksheet name

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
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
How do you get a macro to reference the worksheet it is being run Michelle D[_2_] Excel Discussion (Misc queries) 2 August 11th 09 10:17 AM
Newbie Cell Reference Question... UncleRemus New Users to Excel 2 October 30th 05 12:02 PM
Newbie vba - How do I reference cells in another workbook Ian[_10_] Excel Programming 3 June 8th 04 04:30 AM
Newbie help with cell reference carlab68 Excel Programming 4 December 9th 03 09:58 PM
Newbie question on cell reference 2 Mfaces Excel Programming 5 December 9th 03 07:58 PM


All times are GMT +1. The time now is 09:04 AM.

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"