Automatically sort fields in MS Excel
I want to automatically sort fields in excel when entering new data. Suppos开发者_运维百科e I have following data,
Abc
Bcd Efg Hij.If I enter values like 'Cde' or 'fgh', it should automatically get sorted and moved to the appropriate place. How can I do this in MS Excel 2007 ?
Also in my MS Excel 2007, View Code on right click of Sheet as well as Visual Basic & Macros in Developer Tab are disabled. Please help me with your suggestions.
The most elegant way of doing this would be to set up a worksheet macro that runs each time a value is entered into one of the cells in the range you're working with.
This is still possible without using a macro, but it's rather messy. For numeric data, you can combine RANK and VLOOKUP to create an output range that will sort itself when you enter new values into an input range. To deal with text values, you would need to:
- UPPER each sort value
- Convert each character into a number using the CODE function (ASCII only)
- Concatenate all these numbers together
- Apply the VALUE function to stop them being parsed as text
- RANK the concatenated numbers.
- VLOOKUP the ranks, adding extra logic to deal with ties...
It isn't very much extra work to manually sort the table if the extra rows are only occasionally being added, so perhaps neither of these methods is appropriate. This can be done with as few as 5 keystrokes - Ctrl + * to select the whole table once 1 cell is selected, then alt + d > s to bring up the sort box, then enter to sort (a few extra if the sort column isn't already selected by default).
精彩评论