Private Sub CommandButton1_Click()
Dim MyRegion As String
Dim i As Integer
Dim P_count As Integer
Dim q As Integer
Dim P_Loop As Integer
Dim x As Integer
Application.ScreenUpdating = False
P_count = ActiveSheet.PivotTables.Count
i = 1
Range("A2").Value = ListBox1.Value
MyRegion = Range("A2").Text
ProgressBar1.Visible = True
q = 0
x = 1
P_Loop = P_count * Sheets("Report").PivotTables("PivotTable" & i).PivotFields("Client Region").PivotItems.Count
Do
With Sheets("Report").PivotTables("PivotTable" & i).PivotFields("Client Region")
.PivotItems(MyRegion).Visible = True
For Each Pi In .PivotItems
If Pi.Name <> MyRegion Then Pi.Visible = False
q = x / P_Loop * 100
ProgressBar1.Value = q
Application.StatusBar = q & "% Complete"
x = x + 1
Next Pi
End With
i = i + 1
Loop Until i = P_count + 1
Application.StatusBar = ""
Application.ScreenUpdating = True
Unload Me
'Range("A2").Value = "The following infomation of for " & MyRegion
'Range("A2").Speak
'MsgBox ("The following infomation is for " & MyRegion)
End Sub
Private Sub CommandButton2_Click()
Dim CurrentChart As Chart
Dim fname As String
Set CurrentChart = Sheets("Report").ChartObjects(ComboBox1.Value).Chart
fname = ThisWorkbook.Path & "\temp.GIF"
CurrentChart.Export Filename:=fname, FilterName:="GIF"
Image1.Picture = LoadPicture(fname)
End Sub
Private Sub UserForm_Initialize()
With ListBox1
.AddItem "Central"
.AddItem "Eastern Cape"
.AddItem "Kwa-Zulu Natal"
.AddItem "Limpopo"
.AddItem "Mpumalanga"
.AddItem "Northern Gauteng"
.AddItem "Southern Gauteng"
.AddItem "Western Cape"
End With
With ComboBox1
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "7"
.AddItem "8"
End With
End Sub