transposing then ranking

voltages

New Member
Joined
Feb 27, 2008
Messages
25
I've been figuring out how this is done. This is the scenario. Every person offers pairs of bids every hour and everyday. Now I want to transform the bids to a single column and rank them which is the lowest to the highest in rank.

I cant get the formula right, i wonder if excel can do this or not. Please help, thanks.


I have attached an excel file.

http://www.mediafire.com/?vf78d7zog356g

Voltages
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
voltages,

Thanks for the workbook.


Sample raw data in worksheet Sheet1, with titles beginning in cell A5:


Excel Workbook
ABCDEFGHIJKLMNO
5DATEHOURNameQUANTITY 1PRICE 1QUANTITY 2PRICE 2QUANTITY 3PRICE 3QUANTITY 4PRICE 4QUANTITY 5PRICE 5QUANTITY 6PRICE 6
61/26/20111Alice51067.30
71/26/20111Benie00.012400.014201000.194501200.194602400.19
81/26/20111Charlie07000.1967000.19127200.19188000.19
91/26/20111Daisy07500.1967500.19127700.09187800.09
101/26/20111Joe25035040675.1945700.19
111/26/20111Kent010910321091040119104512910
121/26/20111Robbie9060.1111060.111642995.11
13
Sheet1





After the macro in a new worksheet Results:


Excel Workbook
ABCDEF
1DateHourNameQUANTITYPriceRank
21/26/20111Alice5101
31/26/20111Alice67.301
41/26/20111Benie00.015
51/26/20111Benie2400.015
61/26/20111Benie4201000.1911
71/26/20111Benie4501200.1912
81/26/20111Benie4602400.1913
91/26/20111Charlie07000.1915
101/26/20111Charlie67000.1915
111/26/20111Charlie127200.1917
121/26/20111Charlie188000.1922
131/26/20111Daisy07500.1918
141/26/20111Daisy67500.1918
151/26/20111Daisy127700.0920
161/26/20111Daisy187800.0921
171/26/20111Joe2501
181/26/20111Joe3501
191/26/20111Joe40675.199
201/26/20111Joe45700.1910
211/26/20111Kent01091023
221/26/20111Kent321091023
231/26/20111Kent401191025
241/26/20111Kent451291026
251/26/20111Robbie9060.117
261/26/20111Robbie11060.117
271/26/20111Robbie1642995.1114
28
Results





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub TransposeRank()
' hiker95, 03/20/2011
' http://www.mrexcel.com/forum/showthread.php?t=537333
Dim w1 As Worksheet, wR As Worksheet
Dim LR As Long, LC As Long, NR As Long
Dim a As Long, aa As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wR = Worksheets("Results")
wR.UsedRange.Clear
Set wR = Worksheets("Results")
wR.Range("A1:F1") = [{"Date","Hour","Name","QUANTITY","Price","Rank"}]
LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
For a = 6 To LR Step 1
  LC = w1.Cells(a, Columns.Count).End(xlToLeft).Column
  For aa = 4 To LC Step 2
    NR = wR.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    wR.Range("A" & NR).Resize(, 3).Value = w1.Range("A" & a).Resize(, 3).Value
    wR.Range("D" & NR).Resize(, 2).Value = w1.Range(w1.Cells(a, aa), w1.Cells(a, aa + 1)).Value
  Next aa
Next a
LR = wR.Cells(Rows.Count, 1).End(xlUp).Row
wR.Range("A2:A" & LR).NumberFormat = "m/d/yyyy"
wR.Range("F2").Formula = "=RANK(E2,$E$2:$E$" & LR & ",1)"
wR.Range("F2").AutoFill Destination:=wR.Range("F2:F" & LR)
wR.UsedRange.Columns.AutoFit
wR.Activate
Application.ScreenUpdating = True
End Sub



Save you workbook, Save As, a macro enabled workbook.



Then run the TransposeRank macro.


Each time you run the TransposeRank macro, the prior data in worksheet Results will be removed.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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