Sorting

Status
Not open for further replies.

JOEE1979

Active Member
Joined
Dec 18, 2022
Messages
250
Office Version
  1. 365
Platform
  1. Windows
Hello
Can someone please let me know what I'm doing wrong?
I'm still new to the VBA world
I have a bunch of tables that I've created on 1 spreadsheet and hoping I can sort them out at the end of the day
Thanks


Sub EndODay()
'create loop through column F (assuming that's where the Status col. is)
Dim c As Range
For Each c In Range("F10:F80")
If c.Value = "Completed" Then
'will clear the active row's columns A through F
Range(Cells(c.Row, 1), Cells(c.Row, 6)).ClearContents
End If
Next c

'Sort by column F
With ActiveSheet.Sort
.SortFields.Add Key:=Range("F10"), Order:=xlAscending
.SetRange Range("a10:f80")
.Header = xlYes
.Apply

'create loop through column J (assuming that's where the Status col. is)
Dim c As Range
For Each c In Range("J50:J67")
If c.Value = "Yes" Then
'will clear the active row's columns H through J
Range(Cells(c.Row, 8), Cells(c.Row, 10)).ClearContents
End If
Next c

'Sort by column F
With ActiveSheet.Sort
.SortFields.Add Key:=Range("J50"), Order:=xlAscending
.SetRange Range("J50:J67")
.Header = xlYes
.Apply

'create loop through column N (assuming that's where the Status col. is)
Dim c As Range
For Each c In Range("N69:N94")
If c.Value = "Yes" Then
'will clear the active row's columns G through N
Range(Cells(c.Row, 7), Cells(c.Row, 14)).ClearContents
End If
Next c

'Sort by column N
With ActiveSheet.Sort
.SortFields.Add Key:=Range("N69"), Order:=xlAscending
.SetRange Range("N69:N94")
.Header = xlYes
.Apply

'Sort by column M
With ActiveSheet.Sort
.SortFields.Add Key:=Range("M50"), Order:=xlAscending
.SetRange Range("M50:M67")
.Header = xlYes
.Apply

End With
End Sub




Shift Update.xlsm
ABCDEFGHIJKLMN
1# of units returned to serviceSign in / Found in:
2# of MTO's completed
3Oshawa Shift Update# of BDN'sAM Mechanic
4# of Sign In'sPM Mechanic
5December 18, 202211:17:12 PM# of CAD/AVLOVN Mechanic
6# of units waiting for reinspectUnitW/O #ActivityCorrected
7# of units waiting for paperwork
8Michael Gonsalves# of absentee
9Overnight 20:00-05:00# of OT
10UNITMechanicW/O #ActivityClassificationStatus
111212Anthony Ayoungsdcsboot5454On Hold
122122516516545124515151On Hold
1321225165165455151On Hold
144152Bratish Panjaratnam123456789056446Running RepairTSS
15
16
17
18
19
20
21
22
23
24
25
26
27
28MTO STICKEREDRETURNED TO SERVICEWaiting for Paperwork
29
30
31
32
33
34
35
36
37
38Waiting for Re-inspect
39
40
41
42
43
44
45
46
47
48CAD / AVL / PrestoAttendance
49
50UnitTicket #RepairedReasonEmployeePosition
51dvdvdfvdfv
52ololuikuik
53dfvfdvdfvYes
54
55
56gyhukiu
57
58
59
60
61
62
63
64
65
66
67
68UnitW/O #VendorOff PropertyAway DateActivityEmail SentOn Property
69
70
71
72
73
74
75
76
77
78
79
80
81SHIFT NOTES
82
83MORNING
84
85
86
87AFTERNOON
88
89
90
91OVER NIGHT
92
93
94
Shift Update
Cell Formulas
RangeFormula
A5A5=TODAY()
C5C5=NOW()
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You don't have End With at the end of each With statement
 
Upvote 0
@JOEE1979
  1. When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug. My signature block below has more details.
  2. Isn't this just a continuation of this thread?
 
Upvote 0
@JOEE1979
  1. When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug. My signature block below has more details.
  2. Isn't this just a continuation of this thread?
Yes, Sorry, please delete this thread, I will continue it on the last thread
 
Upvote 0
I will just close this thread so, yes, continue in the existing thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,352
Messages
6,124,449
Members
449,160
Latest member
nikijon

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