Automatically Sorting as You Enter Information
Is there is a way to automatically sort every time new data to a worksheet?
It would be great, for instance, that when data is added such as a new name to a list of names that the names are automatically sorted to always be in order.
This is possible by using a macro that is triggered whenever something new is entered in the worksheet.
For instance, add a macro to the code for a worksheet that is triggered when something in the worksheet changes.
(To view the code window by right-clicking the worksheet tab and choosing View Code from the resulting Context menu.)
The following is an example of one such simple macro
Example 1
The macro assumes that you want to sort on the data in column A and that there is a header in cell A1.
If the names are in a different column, just change the cell A2 reference to a different column, such as B2, C2, etc
Example 2
The following version of the macro sorts the data only when a change is made in column A.
No comments:
Post a Comment