#1   Report Post  
Posted to microsoft.public.excel.misc
texansgal
 
Posts: n/a
Default Sorting

In Excel, I want to sort by a certain column. When I add more to the bottom,
is there a formula to make the NEW entries AUTOMATICALLY add in the correct
place?
  #2   Report Post  
Posted to microsoft.public.excel.misc
grahammal
 
Posts: n/a
Default Sorting


Sub Button9_Click()
' Checks for end of list
For a = 1 To 200
If Sheets("Sheet1").Range("A" & a) = "" Then GoTo 35 Else GoTo 30
30 Next a
' Sets String
35 newString = Sheets("Sheet1").Range("D5") ' New entry
' Checks to see if new entry already exists
For b = 1 To 200
If Sheets("Sheet1").Range("A" & b) = newString Then GoTo 44 Else GoTo_
50
44 Sheets("Sheet1").Range("D5") = "New entry already exists": GoTo 100
50 Sheets("Sheet1").Range("A" & a) = newString
Sheets("Sheet1").Range("D5") = newString & " has been_ added to list"
' Performs column "A" sort
Sheets("Sheet1").Select
Range("A1", "A" & a).Select
For c = Selection.Columns.Count To 1 Step -1
Selection.Sort _
Key1:=Selection.Columns.Item(c), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Next c
100 End Sub

The above is an extract from something I use in an electronic form I
wrote.
Basically it Checks to see how long the existing list is.
Looks at cell D5 for the new addition and calls it newString.
Looks down the list to see if it already exists.
If it does it tells you and ends, if not it adds it to the end of the
list.
It now sorts column A.
My search list is 200 rows long, you can make it as long as you like.

Is this of any help.
Pete


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=542508

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
Sorting SnobbishJade New Users to Excel 6 April 2nd 06 02:08 AM
Sorting Data in ascending order sharon2006 Excel Discussion (Misc queries) 1 March 14th 06 01:07 AM
sorting non contiguous ranges gsh20 Excel Discussion (Misc queries) 1 September 8th 05 04:50 PM
sorting number in ascending order Janice Lee via OfficeKB.com Excel Discussion (Misc queries) 2 April 8th 05 10:31 PM
Adding a KeyID column for sorting Rebecca New Users to Excel 3 February 20th 05 07:09 PM


All times are GMT +1. The time now is 03:59 AM.

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"