If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Problem with Variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-10, 13:40
mike703 mike703 is offline
Registered User
 
Join Date: Mar 2005
Posts: 23
Problem with Variables

I am currently trying to type code that will verify the data of two column fields (FM, COSTTYP) in a pivot table. There is probably an easier way to go about it, but would like the code to identify that for each item within the "FM" field (ex. "2010/10"), there is also corresponding "Actual" data within the "COSTTYPE"field.
Code:
 Set PT = ActiveSheet.PivotTables(1)
    
    ForMth = PT.PivotFields("FM")
     For Each ForMth In PT.PivotFields("FM").PivotItems
                
     n = ForMth.Name
        
        On Error GoTo NotVisible
        PT.PivotSelect "Actual n", xlDataAndLabel, True
I am using a variable rather than try and hard code each individual pivot item under "FM". The problem is within the bolded line which will not recognize that n = the current pivot item. Anyone have a better idea how to rephrase the code or even a different approach?
Reply With Quote
  #2 (permalink)  
Old 11-16-10, 18:45
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Should it be this?
Code:
PT.PivotSelect "Actual " & n, xlDataAndLabel, True
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On