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
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