He conseguido solucionarlo, os lo pongo por si a alguien le fuera util.
El problema era poner visible a false a todas las opciones (sin que hubiera ninguna en true) por eso había que poner primero una opción a true y luego todos los demás a false. Pongo el ejemplo:
Worksheets("Diego").PivotTables("Diego1").PivotFields("MES").CurrentPage = "(All)"
With Worksheets("Diego").PivotTables("Diego1").PivotFields("MES")
'tengo que controlar el mes para no ponerlo en false
.PivotItems(mes).Visible = True
If Not mes = "ENERO" Then
.PivotItems("ENERO").Visible = False
End If
If Not mes = "FEBRERO" Then
.PivotItems("FEBRERO").Visible = False
End If
If Not mes = "MARZO" Then
.PivotItems("MARZO").Visible = False
End If
If Not mes = "ABRIL" Then
.PivotItems("ABRIL").Visible = False
End If
If Not mes = "MAYO" Then
.PivotItems("MAYO").Visible = False
End If
If Not mes = "JUNIO" Then
.PivotItems("JUNIO").Visible = False
End If
If Not mes = "JULIO" Then
.PivotItems("JULIO").Visible = False
End If
If Not mes = "AGOSTO" Then
.PivotItems("AGOSTO").Visible = False
End If
If Not mes = "SEPTIEMBRE" Then
.PivotItems("SEPTIEMBRE").Visible = False
End If
If Not mes = "OCTUBRE" Then
.PivotItems("OCTUBRE").Visible = False
End If
If Not mes = "NOVIEMBRE" Then
.PivotItems("NOVIEMBRE").Visible = False
End If
If Not mes = "DICIEMBRE" Then
.PivotItems("DICIEMBRE").Visible = False
End If
End With
El problema era poner visible a false a todas las opciones (sin que hubiera ninguna en true) por eso había que poner primero una opción a true y luego todos los demás a false. Pongo el ejemplo:
Worksheets("Diego").PivotTables("Diego1").PivotFields("MES").CurrentPage = "(All)"
With Worksheets("Diego").PivotTables("Diego1").PivotFields("MES")
'tengo que controlar el mes para no ponerlo en false
.PivotItems(mes).Visible = True
If Not mes = "ENERO" Then
.PivotItems("ENERO").Visible = False
End If
If Not mes = "FEBRERO" Then
.PivotItems("FEBRERO").Visible = False
End If
If Not mes = "MARZO" Then
.PivotItems("MARZO").Visible = False
End If
If Not mes = "ABRIL" Then
.PivotItems("ABRIL").Visible = False
End If
If Not mes = "MAYO" Then
.PivotItems("MAYO").Visible = False
End If
If Not mes = "JUNIO" Then
.PivotItems("JUNIO").Visible = False
End If
If Not mes = "JULIO" Then
.PivotItems("JULIO").Visible = False
End If
If Not mes = "AGOSTO" Then
.PivotItems("AGOSTO").Visible = False
End If
If Not mes = "SEPTIEMBRE" Then
.PivotItems("SEPTIEMBRE").Visible = False
End If
If Not mes = "OCTUBRE" Then
.PivotItems("OCTUBRE").Visible = False
End If
If Not mes = "NOVIEMBRE" Then
.PivotItems("NOVIEMBRE").Visible = False
End If
If Not mes = "DICIEMBRE" Then
.PivotItems("DICIEMBRE").Visible = False
End If
End With