Ordering a List

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Hi

I am attempting to have random entries placed in an ordered summary. Column "A" has the random names. Column "C" has the ordered summary that I need. I will be adding continuously to column "A" so the formulas in column "C" must be dynamic in nature to cater for the additions.

Thanks

Steve
Excel Workbook
ABC
1LISTORDERED
2Black Dog - 1Black Dog - 1
3Red Cat - 1Black Dog - 2
4Blue Fish - 1Black Dog - 3
5Red Cat - 2Blue Fish - 1
6Yellow Rat - 1Green Bird - 1
7Red Cat - 3Red Cat - 1
8Black Dog - 2Red Cat - 2
9Yellow Rat - 2Red Cat - 3
10Green Bird - 1Red Cat - 4
11Red Cat - 4Yellow Rat - 1
12Black Dog - 3Yellow Rat - 2
13Yellow Rat - 3Yellow Rat - 3
Sheet1
Excel 2007
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Not sure about formulas, it can be done with a worksheet level event VBA code. Is that OK?
 
Upvote 0
Hi Shrivallabha

As a last resort, a macro / code would do however, I'm better with formulas than with macro or code. Preference is a formula.

Steve
 
Upvote 0
There are some fantastic guys on this forum who will surely let us know if that can be done and how.

Meanwhile, you can use this code. Right click on the worksheet tab, choose View Code option and then paste the code in the VBE coding window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lLastRow As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
lLastRow = Range("A" & Rows.Count).End(xlUp).Row
On Error GoTo ResetSettings
If Target.Column = 1 Then
Range("A2:A" & lLastRow).Copy Destination:=Range("B2")
Range("B1:B" & lLastRow).Sort Key1:=Range("B2"), Order1:=xlAscending, _
Header:=xlYes, MatchCase:=False, dataoption1:=xlSortNormal, Orientation:=xlSortColumns, _
SortMethod:=xlPinYin
End If
ResetSettings:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Hi

It is not working but I suspect it has to do with my ignorance of code. I have copied and pasted as suggested.

The actual sheet that I am using (which is slightly different to the simple example that I posted) is as follows -

Unsorted entries commence in cell B3 and entries are added down from cell B3. Meanwhile the sorted summary list commences in cell R3 and works downwards. All I did was replace the relevant code references with these starting cells. Not sure if that was all I had to do. I have shutdown and restarted Excel but it is still not working.

In the code, I have changed references to "A" to "B" and references to "B" to "R". I haven't changed anything else.

Steve
 
Upvote 0
You almost did it correctly.

In this event Target means the cell that you changed.

You wouldn't want this code to run if the cell changed was not in this column and slow down the work.

So to check if the concerned column ("B") is changing, we need to change:
Code:
If Target.Column = 1 Then
To:
Code:
If Target.Column = 2 Then

That should make it work.
 
Upvote 0
Really sorry but I don't understand the comments. I have changed the code as suggested but still not working.

Are you able to provide me with an email address via a PM so that I might be able to send you the spreadsheet ?

Thanks

Steve
 
Upvote 0
OK. I have PM'ed it as I guess, taking a look at the spreadsheet is possibly the only way to reach a quick conclusion.
 
Upvote 0
1. Will this format be constant (no change with your actual)?
2. You do not need last row which is totals. Correct?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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