Data Sorting for each row and column ---- URGENT

MASOODAHMAD

Board Regular
Joined
Mar 28, 2012
Messages
105
Platform
  1. MacOS
Hi,

I want to sort the data from Highest (Old price) to Lowest (Old Price) for each product in the row. Please remember that it should not be sorted columnar wise. The New price in each Row should intact with it's corresponding Old price.

The data is given below:
Version:1.0 StartHTML:0000000170 EndHTML:0000016601 StartFragment:0000001567 EndFragment:0000016555 SourceURL:file://localhost/Users/agi-sony/Documents/Sorting.xls <style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: windowtext; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Verdana; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl24 { border: 0.5pt solid windowtext; }.xl25 { background: none repeat scroll 0% 0% rgb(204, 255, 255); }.xl26 { font-weight: 700; background: none repeat scroll 0% 0% rgb(255, 204, 153); }.xl27 { font-weight: 700; background: none repeat scroll 0% 0% rgb(255, 204, 153); }</style>
ProductsOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew Price
Apple£27.50£23.38£20.00£17.00£8.00£6.80£28.00£23.80£35.00£29.75£24.50£20.83£14.00£11.90£17.50£14.88
Guava£17.50£14.00£15.00£12.00£25.00£20.00£12.50£10.00£20.00£16.00£22.50£18.00£21.00£16.80£28.00£22.40
Mangoes£35.00£28.00£24.50£19.60£21.00£16.80£17.50£14.00£28.00£22.40£18.00£14.40£40.00£32.00£25.00£20.00
Pineapple£3.00£2.40£30.00£24.00£65.00£52.00£50.00£40.00£35.00£28.00£45.50£36.40£42.00£33.60£70.00£56.00
Watermelon£3.00£2.40£30.00£24.00£65.00£52.00£50.00£40.00£35.00£28.00£45.50£36.40£42.00£33.60£70.00£56.00
Melon£27.50£23.38£28.00£23.80£8.50£7.23£18.00£15.30£30.00£25.50£20.00£17.00£21.00£17.85£17.50£14.88
Cherries£24.00£19.20£35.00£28.00£42.00£33.60£24.50£19.60£40.00£32.00£45.00£36.00£21.00£16.80£28.00£22.40
Strawberry£24.50£19.60£24.00£19.20£40.00£32.00£45.00£36.00£35.00£28.00£17.50£14.00£29.50£23.60£21.00£16.80
Grapes£50.00£40.00£45.00£36.00£35.00£28.00£40.00£32.00£80.00£64.00£42.00£33.60£25.00£20.00£60.00£48.00
Pomegranate£10.00£9.00£7.00£6.30£2.00£1.80£3.00£2.70£5.00£4.50£8.50£7.65£9.00£8.10£1.75£1.58
Plum£15.00£12.00£12.00£9.60£8.00£6.40£17.50£14.00£18.50£14.80£3.00£2.40£14.00£11.20£20.00£16.00
Pear£15.00£13.50£8.00£7.20£10.00£9.00£12.50£11.25£16.00£14.40£6.00£5.40£25.00£22.50£20.00£18.00
£20.00£16.00£18.00£14.40£14.00£11.20£12.00£9.60£30.00£24.00£25.00£20.00£17.50£14.00£21.00£16.80
£10.00£9.00£20.00£18.00£17.50£15.75£14.00£12.60£18.00£16.20£16.00£14.40£8.00£7.20£12.50£11.25
£3.00£2.40£30.00£24.00£65.00£52.00£50.00£40.00£35.00£28.00£45.50£36.40£42.00£33.60£70.00£56.00

<col style="" width="85"> <col span="16" width="75"> <tbody>
</tbody>



I have done one row manually:

Version:1.0 StartHTML:0000000170 EndHTML:0000002679 StartFragment:0000001551 EndFragment:0000002626 SourceURL:file://localhost/Users/agi-sony/Documents/Sorting.xls <style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: windowtext; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Verdana; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl24 { border: 0.5pt solid windowtext; }.xl25 { font-weight: 700; background: none repeat scroll 0% 0% rgb(255, 204, 153); }</style>
Apple£35.00£29.75£28.00£23.80£27.50£23.38£24.50£20.83£20.00£17.00£17.50£14.88£14.00£11.90£8.00£6.80

<col style="" width="85"> <col span="16" width="75"> <tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this
Copy the headers to Sheet2

With Sheet2
In A2
Code:
=IF(Sheet1!A2="","",Sheet1!A2)
Drag/Fill Down
In B2
Code:
=IF(ISODD(COLUMN(A1)),LARGE(INDEX((Sheet1!$B$1:$Q$1=Sheet1!$B$1)*Sheet1!$B2:$Q2,,),INT(COLUMN(A1)/2)+1),INDEX(Sheet1!$B2:$Q2,MATCH(A2,Sheet1!$B2:$Q2,0)+1))
Drag Across to Column Q, then Down

This should work provided there are no Duplicate "Old Prices" in any one Row.
 
Upvote 0
Sorry Marcol, It is not working!!!

There are Duplicate Old and New prices. Please suggest some other formula or VBA.
 
Upvote 0
I copy hiker95's signature which is a great help to upload files: "If you are not able to give us screenshots you can upload your workbook to Box Net, mark the workbook for sharing, and provide us with a link to your workbook."
 
Upvote 0
Try this ...
With Sheet2
Drag A2 Down

In A2
Code:
=IF(ISODD(COLUMN(A1)),ROUND(LARGE(INDEX((Sheet1!$B$1:$Q$1=Sheet1!$B$1)*(Sheet1!$B2:$Q2+(COLUMN($A:$P)/10^6)),,),INT(COLUMN(A1)/2)+1),2),
INDEX(Sheet1!$B2:$Q2,MOD(LARGE(INDEX((Sheet1!$B$1:$Q$1=Sheet1!$B$1)*(Sheet1!$B2:$Q2+(COLUMN($A:$P)/10^6)),,),COLUMN(A:A)/2)*10^6,100)+1))
Drag Across to Column Q, then Down

Excel Workbook
ABCDEFGHIJKLMNOPQ
1ProductsOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew PriceOld PriceNew Price
2Apple35.0029.7528.0023.8027.5023.3824.5020.8320.0017.0017.5014.8814.0011.908.006.80
3Guava28.0022.4025.0020.0022.5018.0021.0016.8020.0016.0017.5014.0015.0012.0012.5010.00
4Mangoes40.0032.0035.0028.0028.0022.4025.0020.0024.5019.6021.0016.8018.0014.4017.5014.00
5Pineapple70.0056.0065.0052.0050.0040.0045.5036.4042.0033.6035.0028.0030.0024.003.002.40
6Watermelon70.0056.0065.0052.0050.0040.0045.5036.4042.0033.6035.0028.0030.0024.003.002.40
7Melon30.0025.5028.0023.8027.5023.3821.0017.8520.0017.0018.0015.3017.5014.888.507.23
8Cherries45.0036.0042.0033.6040.0032.0035.0028.0028.0022.4024.5019.6024.0019.2021.0016.80
9Strawberry45.0036.0040.0032.0035.0028.0029.5023.6024.5019.6024.0019.2021.0016.8017.5014.00
10Grapes80.0064.0060.0048.0050.0040.0045.0036.0042.0033.6040.0032.0035.0028.0025.0020.00
Sheet2
 
Upvote 0
Hi Marcol,

I tried your formula, copied the first formula in A2 and the latter in B2, here is my result:

The cell range is :
Row 1 is blank
Values range: A2:Q13


Version:1.0 StartHTML:0000000105 EndHTML:0000012381 StartFragment:0000001255 EndFragment:0000012335 <style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: windowtext; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Verdana; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl24 { }</style>
Apple35.029.828.027.524.520.820.017.517.7#REF!14.912.614.011.98.06.8
Guava28.025.022.518.021.016.820.016.017.514.012.012.511.215.010.08.0
Mangoes40.032.035.028.028.022.425.021.022.424.519.617.518.014.414.011.2
Pineapple70.065.045.536.442.033.640.032.035.028.024.050.03.02.41.930.0
Watermelon70.065.045.536.442.033.640.032.035.028.024.050.03.02.41.930.0
Melon30.025.527.523.423.818.021.017.920.017.019.9#REF!17.58.515.313.0
Cherries45.036.040.032.028.024.528.042.024.019.221.016.819.615.715.435.0
Strawberry36.028.835.028.029.523.624.519.621.040.019.245.017.514.015.724.0
Grapes80.064.060.035.050.040.042.033.636.040.032.025.632.045.025.020.0
Pomegranate10.09.09.08.18.57.78.17.06.33.05.04.52.72.41.82.0
Plum20.08.018.514.815.012.014.011.214.011.29.617.59.612.03.02.4
Pear25.022.520.010.016.014.415.013.512.28.011.310.17.212.56.05.4

<tbody>
</tbody>
 
Last edited:
Upvote 0
Your original posted sample didn't make it clear that some of your values in thr data table were formula derived.

You should really round these cells to some acceptable degree of accuracy.
e.g.
=ROUND(D11-(D11*10%),5)

To handle the file as it stands try this in B2
Code:
=IF(ISODD(COLUMN(A1)),ROUND(LARGE(INDEX((Sheet1!$B$1:$Q$1=Sheet1!$B$1)*(Sheet1!$B2:$Q2+(COLUMN($A:$P)/10^[COLOR=#ff0000]9[/COLOR])),,),INT(COLUMN(A1)/2)+1),2),
INDEX(Sheet1!$B2:$Q2,MOD(LARGE(INDEX((Sheet1!$B$1:$Q$1=Sheet1!$B$1)*(Sheet1!$B2:$Q2+(COLUMN($A:$P)/10^[COLOR=#ff0000]9[/COLOR])),,),COLUMN(A:A)/2)*10^[COLOR=#ff0000]9[/COLOR],100)+1))

This should clear the #REF! errors
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,462
Members
448,965
Latest member
grijken

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