How to keep columns of data together when sorting on one?

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
303
Office Version
  1. 365
I keep a daily total of counts for several departments for each day. I sort on these counts from largest to smallest in the second column.

I need to keep these counts together with their corresponding departments as the sort order changes day to day (based on the second column).

For example, I've highlighted Finance to show where it changes in the sort order.

First day
Picture1.png


Second day
Picture2.png


Third day
Picture3.png


On 5/28 and 5/29, Finance has the same number of counts and remains in slot 4. But on 6/1, it moves down to slot 5 with a count of 5. I need to keep the other values in the date columns moving along with it (this goes for all departments, of course). I've been doing this manually, so a dynamic formula is what I'm looking for.

To help with this, I'm keeping a table with the history for each date/department.
Picture4.png


What would the formula look like to keep the dates together and as I add to the columns to the dailies and rows for the history table?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Your table is sorting correctly.
 
Upvote 0
Your table is sorting correctly.
Thanks for the reply, Logit. However, the only reason the data is sorting correctly is because I mentioned earlier that I'm having to do it manually. This is not an efficient method.

Do you have suggestions that would make it work with formulas?
 
Upvote 0
This will sort your data :

VBA Code:
Option Explicit

'##### Adjust range as required #####

Sub srtMe()
Dim LastRow As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A2:D100" & LastRow).Sort Key1:=Range("A2:D100" & LastRow), _
       Order1:=xlDescending, Header:=xlYes
End Sub

As for an actual FORMULA ... I am not aware of a formula that will sort your data. That doesn't mean there isn't one ... I've just
never heard of one.
 
Upvote 0
This will sort your data :

VBA Code:
Option Explicit

'##### Adjust range as required #####

Sub srtMe()
Dim LastRow As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A2:D100" & LastRow).Sort Key1:=Range("A2:D100" & LastRow), _
       Order1:=xlDescending, Header:=xlYes
End Sub

As for an actual FORMULA ... I am not aware of a formula that will sort your data. That doesn't mean there isn't one ... I've just
never heard of one.
Thank you, Logit.
 
Upvote 0
You are welcome. Glad to help.

Cheers !
 
Upvote 0

Forum statistics

Threads
1,225,481
Messages
6,185,236
Members
453,283
Latest member
Shortm88

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