Royalbloodi
New Member
- Joined
- Oct 31, 2023
- Messages
- 16
- Office Version
- 365
- Platform
- Windows
So, this is a mouthful. I have a spreadsheet that tracks the statuses of my jobs. I need to be able to click on the sort button sort that sheet by color and relocate all completed work to a secondary sheet where it will be amended after the last row and sorted, also this code needs to reformat the cells where the relocated information was previously, back to white.
Currently, it only sorts the rows by color with this:
Mixed Data in Cells C23 to O51.
Clicking on "Sort All" organizes the rows by Color first.
Relocates the "MOVED TO WORK" Cyan rows to another sheet called Work Order after any other existing rows, sorts them by Request Number and returns the selection cursor to C14.
Resets formatting for relocated rows to white with Bold black text.
Then returns the cursor selection to C23 on JobSort.
Currently, it only sorts the rows by color with this:
VBA Code:
Private Sub CommandButton1_Click()
' Sort rows by RGB color order.
' To add a color, go down to the section for adding colors and enter the RGB color code at the end in place of the (###, ###, ###)
' To change the order of colors, modify the RGB codes below to suit your needs. Use the Sort Order Legend to set up your colors ahead of time.
Range("C23:O51").Select
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Clear
'1 - Sort (LightRed) first.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(244, 132, 132)
'2 - Sort (Orange) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(255, 192, 0)
'3 - Sort (Yellow) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(255, 255, 0)
'4 - Sort (Green) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(146, 208, 80)
'5 - Sort (LightBlue) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(0, 176, 240)
'6 - Sort (LightPurple) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(142, 169, 219)
'7 - Sort (GrayBlue) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(193, 152, 224)
'8 - Sort (RedHold) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(255, 0, 0)
'9 - Sort (TanP&P) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(181, 182, 150)
' ------------------------------------------ADD COLORS BELOW------------------------------------------
' *** ONCE FINISHED, DO NOT FORGET TO REMOVE THE TIC MARKS FROM BEFORE THE LINE OF CODE ***
'10 - Sort (Burgundy) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(175, 19, 3)
'11 - Sort (Cyan) next.
ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(0, 250, 225)
'12 - Sort (Color) next.
' ActiveWorkbook.Worksheets("JobSort").Sort.SortFields.Add(Range("Chg_Date"), _
' xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = _
RGB(###, ###, ###)
With ActiveWorkbook.Worksheets("JobSort").Sort
.SetRange Range("C23:O51")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("C23").Select
End Sub
Mixed Data in Cells C23 to O51.
Clicking on "Sort All" organizes the rows by Color first.
Relocates the "MOVED TO WORK" Cyan rows to another sheet called Work Order after any other existing rows, sorts them by Request Number and returns the selection cursor to C14.
Resets formatting for relocated rows to white with Bold black text.
Then returns the cursor selection to C23 on JobSort.