LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Sort a range of strings using VBA code?

I would like to store a list of names in my spreadsheet. I will probably
use the range of A1 to A? to save my name list. Here's a small
example:

A1 = "Anderson, Tom"
A2 = "Baker, Richard"
A3 = "Foley, Bob"
A4 = "Peterson, Zack"

I will be adding new names to this list every day, so it is NOT
a fixed size list. Suppose tomorrow I need to add
"Carlson, Amanda" to the above list. The ideal sorted list will
be:

A1 = "Anderson, Tom"
A2 = "Baker, Richard"
A3 = "Carlson, Amanda"
A4 = "Foley, Bob"
A5 = "Peterson, Zack"

Does anyone know how to write a VBA "insert and sort" function that
achieves the above task? I am not interested in Excel's built-in sort
features....I would like to accomplish this with VBA code that sorts
or re-arranges a range of strings in cells. It seems to be a matter of
finding where the new name fits in the last, and then pushing all the
other names down by one cell.

The function/sub template might look approximately like this:

Public Sub InsertAndSort (NameBegin as Range, NameFinal as Range, NameToAdd
as String)
'
' Sort code
'
End Sub

I would really appreciate any ideas on how to achieve this.

Thank you!


 
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
Quick method to sort a list of strings? ker_01 Excel Programming 2 October 20th 08 05:21 PM
Use Formula to sort two strings Ray Ray Excel Worksheet Functions 2 January 15th 08 12:37 PM
macro code to sort a range ashish128 Excel Discussion (Misc queries) 5 August 17th 06 05:52 PM
Sort a row of strings, some containing blanks KobusD Excel Programming 8 September 2nd 05 08:39 PM
Replacing VBA code strings by using VBA code? shoba[_2_] Excel Programming 1 June 27th 05 10:42 PM


All times are GMT +1. The time now is 08:55 PM.

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

About Us

"It's about Microsoft Excel"