Skip to main content

Custom sort

Excel allows you to customize the sort order of your data by creating a custom sort order. This can be useful when you have data that does not sort correctly using the built-in sort options, or when you want to sort data in a specific order that is not alphabetical or numerical. To create a custom sort order in Excel: Select the data that you want to sort. Go to the Data tab, in the Sort & Filter group, click on the Sort A-Z button. In the Sort dialog box, select the column that you want to sort by. Click the Options button. Select the "Sort On" option and choose "Custom List" In the Custom List section, select the list you want to use or type in your own list. Click OK to apply the custom sort order. Alternatively, you can also use the VBA code to sort the data by a custom list. Here is an example of VBA code that sorts a range called "MyRange" using a custom list: Copy code With MyRange .Sort Key1:=.Cells(1), Order1:=xlAscending, _ Key2:=.Cells(2), Order2:=xlAscending, _ Key3:=.Cells(3), Order3:=xlAscending, _ Header:=xlGuess, OrderCustom:=Application.Transpose(Array("custom1","custom2","custom3")), MatchCase:=False, Orientation:=xlTopToBottom End With This code sorts the data based on the order of the custom list. The custom list should be an array of the same length as the number of columns you're sorting. It's important to note that you can use multiple custom lists and multiple columns in the same sort.

Comments

Popular posts from this blog

Vlookup with wildcard

The VLOOKUP function in Excel can be used with wildcard characters to find and retrieve data based on a partial match of a lookup value. The wildcard characters that can be used with VLOOKUP are the "*" (asterisk) and "?" (question mark) characters. The "*" (asterisk) character is used to match any sequence of characters, while the "?" (question mark) character is used to match any single character. To use a wildcard character with VLOOKUP, you need to include the wildcard character in the lookup value within quotation marks. For example, to find the price of a product that starts with the letter "A" and has any number of characters after it, you can use the following formula: =VLOOKUP("A*",A1:C10,3,FALSE) This formula will look for the value "A*" in the first column of the range A1:C10, and if it finds a match, it will return the value in the third column of the same row. Similarly, if you want to find a pro...

vlookup with vstack

Get multiple lookup values in single cell