Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ParticipantSort()
- ' Sorts participants by fundraising level and provides segmented results.
- Dim SheetName As String, number As Double
- Application.ScreenUpdating = False
- number = Application.WorksheetFunction.Count(Range("I:I"))
- SheetName = Format(Date, "mmm-dd-yyyy") & " Participant Report"
- Worksheets(1).Name = SheetName
- Sheets.Add After:=ActiveSheet
- Sheets("Sheet1").Select
- Sheets("Sheet1").Name = "Segmented Results"
- ActiveCell.FormulaR1C1 = "Segmented Results"
- Range("A1:C1").Select
- Application.WindowState = xlNormal
- With Selection.Font
- .Name = "Calibri"
- .Size = 20
- .Strikethrough = False
- .Superscript = False
- .Subscript = False
- .OutlineFont = False
- .Shadow = False
- .Underline = xlUnderlineStyleNone
- .ThemeColor = xlThemeColorLight1
- .TintAndShade = 0
- .ThemeFont = xlThemeFontMinor
- End With
- Selection.Font.Bold = True
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- .WrapText = False
- .Orientation = 0
- .AddIndent = False
- .IndentLevel = 0
- .ShrinkToFit = False
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Selection.Merge
- Range("A2").Select
- ActiveCell.FormulaR1C1 = "Group"
- Range("B2").Select
- ActiveCell.FormulaR1C1 = "# of Participants"
- Range("C2").Select
- ActiveCell.FormulaR1C1 = "$ Raised"
- Range("A3").Select
- ActiveCell.FormulaR1C1 = "$0 - $10"
- Range("A4").Select
- ActiveCell.FormulaR1C1 = "$10.01 - $50"
- Range("A5").Select
- ActiveCell.FormulaR1C1 = "$50.01 - $100"
- Range("A6").Select
- ActiveCell.FormulaR1C1 = "$100.01 - $200"
- Range("A7").Select
- ActiveCell.FormulaR1C1 = "$200.01 - $500"
- Range("A8").Select
- ActiveCell.FormulaR1C1 = "$500.01 - $1,000"
- Range("A9").Select
- ActiveCell.FormulaR1C1 = "$1,000.01 - $20,000"
- Columns("A:A").EntireColumn.AutoFit
- Range("A2:C2").Select
- Selection.Font.Bold = True
- With Selection.Font
- .Name = "Calibri"
- .Size = 13
- .Strikethrough = False
- .Superscript = False
- .Subscript = False
- .OutlineFont = False
- .Shadow = False
- .Underline = xlUnderlineStyleNone
- .ThemeColor = xlThemeColorLight1
- .TintAndShade = 0
- .ThemeFont = xlThemeFontMinor
- End With
- Columns("B:B").EntireColumn.AutoFit
- Columns("C:C").EntireColumn.AutoFit
- Range("C3:C9").Select
- Selection.Style = "Currency"
- Range("A2:C9").Select
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideHorizontal)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- With Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideHorizontal)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- Range("B3").Select
- Worksheets(1).Select
- Columns("A:B").Select
- Selection.Delete Shift:=xlToLeft
- Columns("B:B").Select
- Selection.Delete Shift:=xlToLeft
- Columns("D:D").EntireColumn.AutoFit
- Range("D1").Select
- ActiveCell.FormulaR1C1 = "Reg Date"
- Range("D2").Select
- Columns("D:D").EntireColumn.AutoFit
- Range("E1").Select
- ActiveCell.FormulaR1C1 = "Captain"
- Columns("M:N").Select
- Selection.Delete Shift:=xlToLeft
- Columns("N:Y").Select
- Selection.Delete Shift:=xlToLeft
- Selection.Delete Shift:=xlToLeft
- Range("P5").Select
- ActiveWindow.SmallScroll ToRight:=-4
- Columns("K:K").Select
- Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
- Columns("L:L").Select
- Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
- Range("K1").Select
- ActiveCell.FormulaR1C1 = "$ Raised (Include Reg.)"
- Range("K1").Select
- Selection.Copy
- Range("L1").Select
- ActiveSheet.Paste
- Range("K2").Select
- Application.CutCopyMode = False
- Range("K2").Select
- ActiveCell.FormulaR1C1 = "=SUM(RC[-3]:RC[-1])"
- Range("K2").Select
- Selection.AutoFill Destination:=Range("K2", Range("K" & number))
- Range("K2", Range("K" & number)).Select
- Selection.Copy
- Columns("K:K").Select
- Application.CutCopyMode = False
- Selection.Copy
- Columns("L:L").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Columns("F:K").Select
- Range("K1").Activate
- Application.CutCopyMode = False
- Selection.Delete Shift:=xlToLeft
- Range("F1").Select
- ActiveCell.FormulaR1C1 = "$ Raised (Include Reg.)"
- Range("F2").Select
- Columns("F:F").EntireColumn.AutoFit
- Range("G1").Select
- ActiveCell.FormulaR1C1 = "Goal"
- Range("G2").Select
- Worksheets(1).Activate
- Range("H1").Select
- ActiveCell.FormulaR1C1 = "Sent Emails"
- Range("H2").Select
- Columns("H:H").EntireColumn.AutoFit
- With ActiveWindow
- .SplitColumn = 0
- .SplitRow = 1
- End With
- ActiveWindow.FreezePanes = True
- Columns("A:F").Select
- Columns("I:I").EntireColumn.AutoFit
- Range("I3").Select
- Columns("B:B").EntireColumn.AutoFit
- Columns("C:C").EntireColumn.AutoFit
- Columns("A:A").EntireColumn.AutoFit
- Columns("A:I").Select
- Selection.AutoFilter
- Range("F2").Select
- Columns("F:F").EntireColumn.AutoFit
- ActiveWorkbook.Worksheets(1).AutoFilter.Sort.SortFields. _
- Add Key:=Range("F1", Range("F" & number)), SortOn:=xlSortOnValues, Order:=xlDescending, _
- DataOption:=xlSortTextAsNumbers
- With ActiveWorkbook.Worksheets(1).AutoFilter.Sort
- .Header = xlYes
- .MatchCase = False
- .Orientation = xlTopToBottom
- .SortMethod = xlPinYin
- .Apply
- End With
- Columns("F:F").Select
- Selection.FormatConditions.AddColorScale ColorScaleType:=3
- Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
- Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
- xlConditionValueLowestValue
- With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
- .Color = 7039480
- .TintAndShade = 0
- End With
- Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
- xlConditionValuePercentile
- Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50
- With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
- .Color = 8711167
- .TintAndShade = 0
- End With
- Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
- xlConditionValueHighestValue
- With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
- .Color = 8109667
- .TintAndShade = 0
- End With
- Range("G3").Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:="<=10", _
- Operator:=xlAnd
- Range("J1").Select
- ActiveCell.FormulaR1C1 = "=SUBTOTAL(2,C[-4])"
- Range("K1").Select
- ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,C[-5])"
- Range("J1:K1").Select
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B3:C3").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Columns("C:C").ColumnWidth = 12
- Range("B4").Select
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:=">=10.01" _
- , Operator:=xlAnd, Criteria2:="<=50"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B4:C4").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Range("B5:C5").Select
- Worksheets(1).Activate
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:=">=50.01" _
- , Operator:=xlAnd, Criteria2:="<=100"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:= _
- ">=100.01", Operator:=xlAnd, Criteria2:="<=200"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B6:C6").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:= _
- ">=200.01", Operator:=xlAnd, Criteria2:="<=500"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B7:C7").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:= _
- ">=500.01", Operator:=xlAnd, Criteria2:="<=1000"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B8:C8").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Worksheets(1).Select
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6, Criteria1:= _
- ">=1000.01", Operator:=xlAnd, Criteria2:="<=20000"
- Application.CutCopyMode = False
- Selection.Copy
- Sheets("Segmented Results").Select
- Range("B9:C9").Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
- Worksheets(1).Activate
- ActiveSheet.Range("$A$1", Range("I" & number)).AutoFilter Field:=6
- Application.CutCopyMode = False
- Selection.ClearContents
- ActiveWindow.SmallScroll ToRight:=-4
- Range("A1").Select
- Sheets("Segmented Results").Activate
- Range("B10").Select
- ActiveCell.FormulaR1C1 = "=SUM(R[-7]C:R[-1]C)"
- Selection.AutoFill Destination:=Range("B10:C10"), Type:=xlFillDefault
- Range("C10").Select
- Selection.Style = "Currency"
- Range("B3:B10").Select
- Selection.NumberFormat = "#,##0"
- Range("B10:C10").Select
- Selection.Font.Bold = True
- Range("B12").Select
- Application.ScreenUpdating = True
- ActiveWorkbook.SaveAs Filename:="C:\Users\" & Environ$("Username") & "\Desktop\" & SheetName, _
- FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
- ActiveWindow.WindowState = xlMaximized
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement