I am trying to sort data imported from a csv file. The data comes in like such:
Columns
A | B
--------
t1 | 1
t3 | 9
t1 | 2
t2 | 5
t1 | 1
t3 | 13
t1 | 3
t3 | 11
t2 | 4
t2 | 7
t3 | 10
t3 | 10
and i want output similar to this:
Columns
D | E | F
----------------
t1 | 1 | 3
t2 | 4 | 7
t3 | 9 | 13
Explanation: Basically what I need to do is find the lowest and highest values from column B for each different value in column A, and list them neatly as shown in the second example.
Ive worked with VBA before, so if this would have to be done via VBA thats fine. Im just at a loss as to how to accomplish this task. Any help would be appreciated.
EDIT: Forgot to mention, if would make the task simpler, its fine if i have to manually sort the data alphabetically based on col A (thus putting same values together)
I agree with @chrisneilsen that a Pivot Table is the best way to go. If you are set on using formulas, you can try using the following (both entered as arrays –
Ctrl+Shift+Enter):In cell
E1, which will represent the minimum value:And in cell
F1, which will represent the maximum value:The general idea is that check to see which values in column
Aare equal to your target value (columnD). The result will be an array of1‘s where there is a match, and usingMINas an example, the maximum of the column + 1. This is done because we want to set this equal to a value that can’t possibly be attained in your current setup, so the maximum value + 1 will ensure thatMINwill return a value that is legitimate.Here is a Pivot Table using Excel 2007. To create, add column headers to your data, select your data and then in the Ribbon click
Insert -> Pivot Table. In the dialog box, you decide where you want to put it (it is commonly put in a New Worksheet, so you can leave the default if you want – I left it in the same worksheet for illustration purposes). From there, you can arrange it by dragging each field so it matches the pictures. For theMax/Minfields, just drag theValuefield into theValuessection twice. Then, in the actual Pivot Table, you can right-click on one of the values in the column and selectSummarize Data By -> Minto summarize by the minimum value for each key: