close

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?


Sub Button9_Click()
' Checks for end of list
For a = 1 To 200
If Sheets(quot;Sheet1quot;).Range(quot;Aquot; amp; a) = quot;quot; Then GoTo 35 Else GoTo 30
30 Next a
' Sets String
35 newString = Sheets(quot;Sheet1quot;).Range(quot;D5quot;) ' New entry
' Checks to see if new entry already exists
For b = 1 To 200
If Sheets(quot;Sheet1quot;).Range(quot;Aquot; amp; b) = newString Then GoTo 44 Else GoTo_
50
44 Sheets(quot;Sheet1quot;).Range(quot;D5quot;) = quot;New entry already existsquot;: GoTo 100
50 Sheets(quot;Sheet1quot;).Range(quot;Aquot; amp; a) = newString
Sheets(quot;Sheet1quot;).Range(quot;D5quot;) = newString amp; quot; has been_ added to listquot;
' Performs column quot;Aquot; sort
Sheets(quot;Sheet1quot;).Select
Range(quot;A1quot;, quot;Aquot; amp; 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: www.excelforum.com/member.php...oamp;userid=20336
View this thread: www.excelforum.com/showthread...hreadid=542508

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()