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: 4
Default suppress unwanted rows in a Pivot Table using VBA, dropdowns & Vlo

I have a pivot table that when I select the PivotItem field "region" the
table updates to show only those countries in that region fine. But I want
to suppress the countries that are not in the region from even showing. I
have a named range "contries" that contains all the coutries and to the right
its region.

I have tried a couple of ways and currently working the below code using a
independent dropdown. When the user changes the dropdown the below code
executer. The test value always comes back as error 1004. I know this means
it is not finding the value in the "Country" named range, but when I put the
Vlookup formula directly in Excel it works fine.

Sub region_control()
Dim myPick As Long
Dim myDD As DropDown
Dim Answer As String
Dim test As Variant

Set myDD = ActiveSheet.DropDowns(Application.Caller)
Answer = myDD.List(myDD.Value)
For Each ci In ActiveSheet.PivotTables("Destination
Sales").PivotFields("country").PivotItems
test = Application.WorksheetFunction.VLookup(ci.Value, countries, 2,
False)
If IsError(test) Then
ci.Visible = False 'if error suppress row
Else
If test = IPos Then
ci.Visible = True 'show this country
Else
ci.Visible = False 'country not part of region
End If
End If
Next
 
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
Can't uncheck boxes in Pivot Table dropdowns Zamboni Excel Discussion (Misc queries) 0 February 5th 08 04:04 PM
Suppress Zeros in a Pivot Table Simon Shaw Excel Discussion (Misc queries) 3 July 18th 07 02:58 PM
Pivot Table -- Suppress blank cells Bharath Rajamani Excel Discussion (Misc queries) 1 October 8th 06 08:02 PM
make Pivot table show only available values in dropdowns Yaron Assa Excel Discussion (Misc queries) 2 April 3rd 06 07:39 AM
Suppress sub totals on pivot table [email protected] Excel Programming 2 June 28th 05 11:01 PM


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