a data ordering question
can i set a formula that i and sort a column of datas in a alphabetical order?? please help me, in urgent.... .... -- 無聊的路人甲 ------------------------------------------------------------------------ 無聊的路人甲's Profile: http://www.excelforum.com/member.php...o&userid=37633 View this thread: http://www.excelforum.com/showthread...hreadid=572482 |
a data ordering question
I believe you may be better off recording a macro to do your sort?
Use Macros | Record New Macro and then go through the process of selecting the information to be sorted and completing the sort. At that point stop recording. Give the macro a friendly name like SortMyData or something more meaningful to you than just Macro1 I have only seen an attempt to sort using formulas done once, and it was done pretty well, but it was very complex. With a macro recorded, you can sort the same group over and over. But I am guessing that you are going to have to do this more than one time and that the number of rows to be sorted is going to change. The macro you record will be very literal minded and will always sort exactly the same group of data you chose when you recorded the macro. This means that if you sorted A1:A10 and then add to it in A11, A12 and beyond, that the new information in A11 and A12, etc. will not be sorted by the macro. You can fix that. Select the data to be sorted and in the cell just above the "A" column indicator where it usually shows you what cell you are working with, type in a name and press the [Enter] key. Now that bunch of data to be sorted is a 'Named Range'. Don't use spaces in the name, something like MyDataTable or ToBeSorted would be fine. Let us assume you named it ToBeSorted Choose Macro | Macros and highlight the macro you recorded and then click on the [Edit] button. You should see code similar to this Range("A1:A10").Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Change the ("A1:A10") in the first line shown to have the name you gave the group of cells, ToBeSorted, so now it would look like Range("ToBeSorted").Select Now you can add to the list by inserting new rows inside of that range. Just adding to the right in new columns or at the bottom will not automatically adjust things, but inserting new rows/columns within it will let your macro sort properly every time. Another way to change the code would be like this, and this assumes that column A contains part of the data to be sorted and that the upper left corner of your area to be sorted is at A1 but this time we will presume that you need to also sort rows all the way over to column F. Make the code look similar to this: Sub Macro1() Dim anyRange As String anyRange = "A1:" & Range("F65536").End(xlUp).Address Range(anyRange).Select 'the sort command goes here unchanged End Sub I hope this helps you and that I didn't confuse you by trying to be too helpful. "無" <無, "聊" <聊," wrote: can i set a formula that i and sort a column of datas in a alphabetical order?? please help me, in urgent.... .... -- 無聊的路人甲 ------------------------------------------------------------------------ 無聊的路人甲's Profile: http://www.excelforum.com/member.php...o&userid=37633 View this thread: http://www.excelforum.com/showthread...hreadid=572482 |
All times are GMT +1. The time now is 12:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com