How to operate my Pivot Table through a VBA userform instead of the workbook

cofelice

New Member
Joined
Jun 18, 2011
Messages
1
I built a really nice program for my work. Basically, I have a userform that gets data from a quality control group and adds it to an excel spreadsheet. Four different areas are being QC'ed. I then have a pivot table that takes the data on that spreadsheet and allows me to get a QC % by entering from drop down controls (date range). The pivot table will read the spreadsheet and give me back the QC %. I want to be able to do the same function but allow users to do it through the userform instead of using the pivit table. I want to be able to hide the pivot table. Below is my code for my pivot table.


Sub FilterPivotDates()
'
Dim dStart As Date
Dim dEnd As Date
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Application.ScreenUpdating = False
On Error Resume Next
dStart = Sheets("Weekly Totals").Range("StartDate").Value
dEnd = Sheets("Weekly Totals").Range("EndDate").Value
Set pt = ActiveSheet.PivotTables(1)
Set pf = pt.PivotFields("Date of Document")
pt.ManualUpdate = True
pf.EnableMultiplePageItems = True
For Each pi In pf.PivotItems
pi.Visible = True
Next pi
For Each pi In pf.PivotItems
If pi.Value < dStart Or pi.Value > dEnd Then
pi.Visible = False
End If
Next pi
Application.ScreenUpdating = False
pt.ManualUpdate = False
Set pf = Nothing
Set pt = Nothing
End Sub

Basically, I would want my userform to have two drop down controls that would allow a date range, just like my pivot table has. I would have four labels representing the four things I QC and text boxes next to each of them that would return the % for each.

If anyone needs anymore info to help me get this let me know and I can send it.

Thanks :)
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top