+ Reply to Thread
Results 1 to 1 of 1

Formatting for Pivot Table use

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Formatting for Pivot Table use

    On my "Steps" sheet I have a cell (B2) that has a value such as "02CPS". I have a pivot table (not one I created; it already exists in the workbook, and it's the one I have to use)which has as a Department "020", which means "02CPS". I have a macro which I want to select the "020" in the dropdown for DeptID, based on the value in cell A1.

    How do I tell my macro that 02CPS equals 020, and retain that value to select in my dropdown? I tried using the below code to convert B2 and paste it into C1.

    Set CurStep = DstWkb.Worksheets("Steps").Range("B2")
             
        For Each cell In CurStep
         'Validate cell contents
         Select Case cell.Text
              Case "01CPS", "02CPS", "03CPS", "04CPS", "05CPS", "06CPS", "07CPS", "08CPS", "09CPS", "10CPS", "11CPS"
    
                  Range("C1").Value = Left("B2" & "000", 2)
    
              Case Else
    
                  Range("C1").Value = Range("B2").Value
    However, it pasted "02CPS" instead of converting it to "020". I'd appreciate any help getting that part right.

    For my second part, once I get the correct valued in C1, how do I use it to select my Department? I've put in this line, but can't test it yet, so don't know if it will work:
     ActiveSheet.PivotTables("PivotTable1").PivotFields("Department").CurrentPage = _
            DstWkb.Worksheets("Steps").Range("C1")
    Any help is greatly appreciated.
    Last edited by Mordred; 08-30-2011 at 01:03 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1