开发者

Automatically sort fields in MS Excel

开发者 https://www.devze.com 2023-02-05 16:21 出处:网络
I want to automatically sort fields in excel when entering new data. Suppos开发者_运维百科e I have following data,

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:

  1. UPPER each sort value
  2. Convert each character into a number using the CODE function (ASCII only)
  3. Concatenate all these numbers together
  4. Apply the VALUE function to stop them being parsed as text
  5. RANK the concatenated numbers.
  6. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消