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.
Bookmarks