Hi all,
I'm using the following code to sort times so the earliest appears first
Probably a simpler way of doing that, but it does exactly what I want it to do (that part at least). I'm trying to add functionality to it, so after sorting by earliest time (in K) in then sorts alphabetically (which would be C) but so it doesn't overwrite the chronological order.
Basically, if the times in K are the same, a secondary sort between those identical times is performed where they appear in alphabetical order.
For context, I'm dealing with a list of names (last names) in C and shift start times in K. So there will be multiple instances of the same time occuring e.g 5 names at 9am, 10 names at 1pm..
Hopefully I'm making sense with my explanation, I've not had a coffee yet so I'm still a bit delirious.
Thanks all
I'm using the following code to sort times so the earliest appears first
VBA Code:
Dim ws As Worksheet
Dim rng As Range
Dim srtcol As Range
Set ws = Worksheets(2)
Set rng = ws.Range("A1:Q1", ws.Range("Q1").End(xlDown))
Set srtcol = ws.Range("K1", ws.Range("K1").End(xlDown))
'sorts by earliest start time in K
rng.Sort Key1:=srtcol, Order1:=xlAscending
Probably a simpler way of doing that, but it does exactly what I want it to do (that part at least). I'm trying to add functionality to it, so after sorting by earliest time (in K) in then sorts alphabetically (which would be C) but so it doesn't overwrite the chronological order.
Basically, if the times in K are the same, a secondary sort between those identical times is performed where they appear in alphabetical order.
For context, I'm dealing with a list of names (last names) in C and shift start times in K. So there will be multiple instances of the same time occuring e.g 5 names at 9am, 10 names at 1pm..
Hopefully I'm making sense with my explanation, I've not had a coffee yet so I'm still a bit delirious.
Thanks all