View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default Seeting up repetitive code

Maybe something like this?
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Month")
Select Case Range("T6")
Case 2
.CurrentPage = "January"
Case 3
.CurrentPage = "February"
Case Else
.CurrentPage = "Whatever"
End Select
End With
--
Charles Chickering

"A good example is twice the value of good advice."


"Matt" wrote:

I want to repeat this code:

ActiveSheet.PivotTables("PivotTable1").PivotFields ("Month").CurrentPage =

in multiple macros...how would I do it? This is my thought thus far but I'm
not sure about the syntax:

Dim repeat As String

repeat =
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Month").CurrentPage = _


If Range("T6").Value = "2"
repeat&"January_2006"
end if

If Range("T6").Value = "3"
repeat&"February_2006"
end if


etc. etc. - any suggestions?