Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA PivotTable Data Selection 2

Status
Not open for further replies.

clouddog9

Technical User
Jul 31, 2009
55
US
I have a pivotTable that has a pivotfield in Columns "A" and "B". The pivotdata starts in Column "C." Is there a line of code to make vba show the detail (in column C) of a specific pivot item (in either columns A or B)? I am currently using the .Find(...) to find the item (as well as application.goto to go to the found cell), then using the activecell.row and then concatenating this with "C" to get the data cell's reference then showing the detail on this cell. (See code below)

Code:
With .Columns(strColLookup)'strColLookup is either "A:A" or "B:B"
   Set rngFound = .Find(What:=strLineDescr, _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlPart, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False, _
                        SearchFormat:=False)
End With
If Not rngFound Is Nothing Then
     varFRow = Range(rngFound.Address).Row
     .Range("C" & varFRow).ShowDetail = True
End If

I was wondering if there was a more effecient way to do this. Thanks in advance.
 
I'm bookmarking this page. Thanks xlbo! This should be the tip of the week.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top