MarkCBB
Active Member
- Joined
- Apr 12, 2010
- Messages
- 497
HI there VBA Guru's
I am using the following code to filter some Pivot Tables on a worksheet, however it takes sometime to run the marco, I would like to have a progress bar in the user form to show the progress of the macro. however I have not been able to insert a progress bar into the user form.
Below is the code that I am using:
I am using the following code to filter some Pivot Tables on a worksheet, however it takes sometime to run the marco, I would like to have a progress bar in the user form to show the progress of the macro. however I have not been able to insert a progress bar into the user form.
Below is the code that I am using:
Code:
Private Sub CommandButton1_Click()
Dim MyRegion As String
Dim i As Integer
Dim P_count As Integer
P_count = ActiveSheet.PivotTables.Count
i = 1
Range("A2").Value = ListBox1.Value
MyRegion = Range("A2").Text
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
Next Pi
End With
i = i + 1
Loop Until i = P_count + 1
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
End Sub