Public Sub CallUserForm()
Dim mpForm As ParameterSelection
Dim wsCombined As Worksheet
Dim mpTotalsRow As Long
Dim mpTotal As Double
Set wsCombined = Worksheets("Combined")
Set mpForm = New ParameterSelection
With mpForm
.Show
If Not .Cancel Then
Call FilterPivot("EnrollmentByGrade", .ISDCode, .DistrictCode, .BuildingCode)
Call FilterPivot("TotalEnrollmentTrend", .ISDCode, .DistrictCode, .BuildingCode)
Call FilterPivot("PivotTable1", .ISDCode, .DistrictCode, .BuildingCode) 'Race/Ethicity Makeup Trend
Call FilterPivot("PivotTable2", .ISDCode, .DistrictCode, .BuildingCode) 'Other Demographic Enrollment Trend
Worksheets("Summary").Range("B3").Value = .ISDCode
Worksheets("Summary").Range("B4").Value = .DistrictCode
Worksheets("Summary").Range("B5").Value = .BuildingCode
If .ISDCode = NoSelection Or .DistrictCode = NoSelection Or .BuildingCode = NoSelection Then
Worksheets("Summary").Range("B6:D8").ClearContents
ElseIf .BuildingCode <> NoSelection Then
mpTotalsRow = Worksheets("EEM").Columns(colEEM.BuildingCode).Find(.BuildingCode, After:=Worksheets("EEM").Cells(1, colEEM.BuildingCode)).Row
Worksheets("Summary").Range("B6").Value = Worksheets("EEM").Cells(mpTotalsRow, colEEM.Address)
Worksheets("Summary").Range("B7").Value = Worksheets("EEM").Cells(mpTotalsRow, colEEM.City) & " " & _
Worksheets("EEM").Cells(mpTotalsRow, colEEM.State) & " " & _
Worksheets("EEM").Cells(mpTotalsRow, colEEM.Zip)
Worksheets("Summary").Range("B8").Value = Worksheets("EEM").Cells(mpTotalsRow, colEEM.Phone)
End If
If .BuildingCode <> NoSelection Then
mpTotalsRow = wsCombined.Columns(colCombined.BuildingCode).Find(.BuildingCode, After:=wsCombined.Cells(1, colCombined.BuildingCode)).Row
ElseIf .DistrictCode <> NoSelection Then
mpTotalsRow = wsCombined.Columns(colCombined.DistrictCode).Find(.DistrictCode, After:=wsCombined.Cells(1, colCombined.DistrictCode)).Row
Else
mpTotalsRow = wsCombined.Columns(colCombined.ISDCode).Find(.ISDCode, After:=wsCombined.Cells(1, colCombined.ISDCode)).Row
End If
With wsCombined
mpTotal = .Cells(mpTotalsRow, colCombined.TotalEnrol).Value
Worksheets("Summary").Range("H3").Value = .Cells(mpTotalsRow, colCombined.American).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I3").Value = .Cells(mpTotalsRow, colCombined.American).Value / mpTotal
Else
Worksheets("Summary").Range("I3").Value = 0
End If
Worksheets("Summary").Range("H4").Value = .Cells(mpTotalsRow, colCombined.Asian).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I4").Value = .Cells(mpTotalsRow, colCombined.Asian).Value / mpTotal
Else
Worksheets("Summary").Range("I4").Value = 0
End If
Worksheets("Summary").Range("H5").Value = .Cells(mpTotalsRow, colCombined.African).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I5").Value = .Cells(mpTotalsRow, colCombined.African).Value / mpTotal
Else
Worksheets("Summary").Range("I5").Value = 0
End If
Worksheets("Summary").Range("H6").Value = .Cells(mpTotalsRow, colCombined.Hispanic).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I6").Value = .Cells(mpTotalsRow, colCombined.Hispanic).Value / mpTotal
Else
Worksheets("Summary").Range("I6").Value = 0
End If
Worksheets("Summary").Range("H7").Value = .Cells(mpTotalsRow, colCombined.Hawaiian).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I7").Value = .Cells(mpTotalsRow, colCombined.Hawaiian).Value / mpTotal
Else
Worksheets("Summary").Range("I7").Value = 0
End If
Worksheets("Summary").Range("H8").Value = .Cells(mpTotalsRow, colCombined.White).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I8").Value = .Cells(mpTotalsRow, colCombined.White).Value / mpTotal
Else
Worksheets("Summary").Range("I8").Value = 0
End If
Worksheets("Summary").Range("H9").Value = .Cells(mpTotalsRow, colCombined.TwoOrMore).Value
If mpTotal <> 0 Then
Worksheets("Summary").Range("I9").Value = .Cells(mpTotalsRow, colCombined.TwoOrMore).Value / mpTotal
Else
Worksheets("Summary").Range("I9").Value = 0
End If
End With
Worksheets("Summary").Range("A1").Value = wsCombined.Cells(mpTotalsRow, colCombined.ISDName).Value & _
IIf(.DistrictCode = NoSelection, "", ", " & wsCombined.Cells(mpTotalsRow, colCombined.DistrictName).Value) & _
IIf(.BuildingCode = NoSelection, "", ", " & wsCombined.Cells(mpTotalsRow, colCombined.BuildingName).Value)
End If
End With
End Sub