Sort problem for stock trades

voodoo

Board Regular
Joined
Apr 7, 2002
Messages
186
I have to perform a tricky sorting problem in Excel for a stock trading company.

First sort is by Sell / Buy (only two options)so quite easy.

Second sort is by numeric Company code (each listed company has a 4 digit code e.g AOL = 4568, Microsoft = 5685, etc). This is the tricky part. Often these shares a bought in one trade and other times in multiple trades.
I have to sort the multiple trades first follwed by the single trades.

This is an example of how the finished product would look.

Buy/Sell Company Code
S 5684
S 5684
S 5684
S 3256
S 3256
S 3256
S 4582
S 1568
S 5255
B 2260
B 2260
B 2260
B 2260
B 3333
B 3333
B 3333
B 1098
B 9856
B 8506

Anyone with ideas about how to sort in this fashion. I was thinking of first sorting by Buy and Sell and putting each goup in a new worksheet then going through row by row and comparing if the Buy/Sell and code is same as the row below. if it is a single trade cut it and placing at after the final row and working through each worksheet like that. Finally pasting the sorted buys after the sorted sells so it looks like the example above. This seems horribly clumsy but I cant think of any other good ideas.

voodoo
 
Thanks aladin but it doesnt quite work.

The result sorts the Sells first and then the buys and then sorts the company codes but it doesnt place the multiple company code entries first followed by the single company code entries.

Maybe I am not making myslef clear but I appreciate you efforts.

In business terms what happens is some clients request to buy or sell at a share within a price range so the one order may be transacted in numerous batches - this is why there are ultiple entries for the one company code. Other times the order is met in one trade only. My client wants the multiple trades done first followed by the single trades.
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Voodoo,
Best solution I could come up with would be to do the intitial sort by Sell/Buy and Customer nums then loop through your cells and create values in another column for a second sort operation.
Would count multiple sells groups, single sells, multiple buys groups, single buys, and resort based upon those values.
Tom
 
Upvote 0
On 2002-04-16 01:11, voodoo wrote:
Thanks aladin but it doesnt quite work.

The result sorts the Sells first and then the buys and then sorts the company codes but it doesnt place the multiple company code entries first followed by the single company code entries.

Maybe I am not making myslef clear but I appreciate you efforts.

In business terms what happens is some clients request to buy or sell at a share within a price range so the one order may be transacted in numerous batches - this is why there are ultiple entries for the one company code. Other times the order is met in one trade only. My client wants the multiple trades done first followed by the single trades.

This is what I get by sorting

A --> Descending
C --> Descending
B --> Ascending

No header row checked:

{"S",1568,6;
"S",1568,6;
"S",1568,6;
"S",2568,3;
"S",2568,3;
"S",2568,3;
"S",1060,1;
"S",2526,1;
"S",3565,1;
"S",5698,1;
"B",1568,6;
"B",1568,6;
"B",1568,6;
"B",2659,3;
"B",2659,3;
"B",2659,3;
"B",1569,1;
"B",8856,1}
 
Upvote 0
Aladin

Maybe i did a typo because your output looks perfect - just what I wanted. I have to leave the office now but I will check it again tommorrow.

Only things is I would not what that number in column C to remain and infact there is already data in column C so it would have to be a column like BF or something (there ae many columns. Maybe this is a problem as I gather the columns have to be aligned.

Thanks alot - your a lifesaver

voodoo
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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