![]() |
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? |
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 |
All times are GMT +1. The time now is 04:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com