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: 151
Default Macro Help in Pivot

Hi all,

I get run time error '1004', unable to get the pivot tables property of the
worksheet class...
please check the code below... I get biz name at B1 and region at B2
Now i want the pivot to show only biz type in b1 cell and region at b2 cell
I want to protect pivot and data sheet, dont want manager to select thro
pivot table.
Is it possible.
can you please fix the error in the code below

Sub Show_item_of_oneField()
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim strPromptPF As String
Dim strPromptPI As String
Dim strPF As String
Dim strPI As String

' strPromptPF = "Please enter Field Name to filter"
' strPromptPI = "Please enter Item Name to filter"
'strPF = InputBox(strPromptPF, "Field Name")
'strPI = InputBox(strPromptPI, "Item Name")
strPF = Range("b1").Value
strPI = Range("b2").Value

Set pt = ActiveSheet.PivotTables(1)
Set pf = pt.PivotFields(strPF)

Application.ScreenUpdating = False
Application.DisplayAlerts = False

On Error Resume Next
With pf
.AutoSort xlManual, .SourceName
For Each pi In pf.PivotItems
If pt.RowFields = strPF Then
pt.RowFields = True
Else
pt.RowFields = False
End If

If .PivotItems = strPI Then
pi.Visible = True
MsgBox pi
Else
pi.Visible = False
MsgBox pi
End If
Next pi
.PivotItems(strPI).Visible = True
.AutoSort xlAscending, .SourceName
End With

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

I need the pivot to be refreshed on click of buttom (having macro).
the important thing is that the user (manager) selects "Biz type" at b1
(validation list); selects "Region" at C1 (validation list)

I want the pivot to show that biz & that region selected
-show Biz type, Region, customer, bil amount, tax1 & tax2
suppress biztype total & region total
show only customer total (bill amount, tax1, tax2)

Eddy Stan
let us come to the below after the above is sorted.
*----------------------------------------------------------
3 more pivots are related to results of this pivot,
like pivot table2:
Customer wise No.of sales, value, Noof sales return, value
for the region & biz type selected in pivot table1
a Graph is attached to pivot table2
*-----------------------------------------------------------

 
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
Looking to remove pivot fields from pivot table via macro S Himmelrich Excel Programming 0 January 16th 09 03:49 PM
Macro on filtering pivot table (pivot fields) = debug markx Excel Programming 2 May 28th 08 09:32 AM
macro on pivot tables / pivot items markx Excel Programming 12 May 9th 08 07:06 PM
macro for a pivot anu Excel Discussion (Misc queries) 2 August 11th 06 04:48 PM
Steps from Macro recorder for Pivot table will not run as a Macro Nancy[_5_] Excel Programming 0 April 2nd 04 10:33 PM


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