Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting Unions

I am trying to find a way of sorting 2 disconnected Ranges
i.e A1:L1 and A3:L3.
Can i make a Union of the 2 ranges and then sort them?
I tried and couldn't.
Thanks in advance,
Alex
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Sorting Unions

Bubble sort may work if Alex's lists are as short as those in his
example, but is one of the slowest sorts known. Sorting 6400 random
strings in Excel 2001 VBA on an 800 mhz Powerbook:

Bubble 164 sec; stable
Selection 61 sec; stable
Insertion 33 sec; stable

Comb 0.62 sec
Shell 0.54 sec

Heap 0.52 sec
Merge 0.38 sec; stable
Quick 0.24 sec

Radix 0.20 sec; stable

The only virtues of bubble sort are that it's simple and sorts stably,
but the same is true of insertion sort, which is five times faster:

Sub InsertionSort(A())
Dim LO&, HI&, I&, J&, V

LO = LBound(A): HI = UBound(A)
For I = LO + 1 To HI
V = A(I)
For J = I To LO + 1 Step -1
If V < A(J - 1) Then A(J) = A(J - 1) Else Exit For
Next J
A(J) = V
Next I
End Sub

This assumes values from both ranges have been read into array A().

Dave Ring

Tom Ogilvy wrote:
No, this isn't supported.

You could do a bubble sort and manage the data yourself.

See John Walkenbach's site for a sample bubble sort.

http://j-walk.com/ss/excel/tips/tip47.htm
How to fill a listbox with unique items

there is code to do a bubble sort toward the bottom of the code on that
page.

Here are some code samples for a selection sort and a bubble sort
http://support.microsoft.com/?id=133135
XL: Using a Visual Basic Macro to Sort Arrays in Microsoft Excel

You would have to adapt them to handle the additional column/row.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unions, intersections or array constants Loadmaster Excel Worksheet Functions 24 May 6th 09 08:11 PM
Sorting Values Without Sorting Formulas SBX Excel Discussion (Misc queries) 2 April 12th 09 11:17 PM
Automatic sorting (giving max and min) based on custom sorting lis Joe Lewis[_2_] Excel Worksheet Functions 4 November 23rd 08 05:12 AM
Sorting VLookup vs Sorting SumProduct Lauren Excel Discussion (Misc queries) 1 August 21st 07 12:19 AM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"