Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005

    Unanswered: 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.
     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?

  2. #2
    Join Date
    Sep 2008
    London, UK
    Should it be this?
    PT.PivotSelect "Actual " & n, xlDataAndLabel, True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts