Macros Automatically Sort
You can do that if you add your sort code to the worksheet change event...
Right click on sheet tab, choose view code and paste the following after
adding your sort code
Private Sub Worksheet_Change(ByVal Target As Range)
'your sortcode here
'remember to first check whether the current cell is in sort range,
otherwise your code will run for all changes
'sample code to check for range
If Intersect(ActiveCell, Range("A1:A10")) Is Nothing Then
MsgBox "The active cell does NOT Intersect A1:A10"
Else
MsgBox "The active cell does Intersect A1:A10"
'you can put your sort code here
End If
End Sub
sample code to check for range
If Intersect(ActiveCell, Range("A1:A10")) Is Nothing Then
MsgBox "The active cell does NOT Intersect A1:A10"
Else
MsgBox "The active cell does Intersect A1:A10"
End If
"Fran" wrote:
In a spreadsheet of expiration dates and names, the sort function can be used
or a Macro can be set up to sort the dates in ascending order. Is there a
way that the dates will automatically sort without having to click sort or
run macro? For example, if the date is changed from 5/21/09 to 5/21/10, we
want excel to sort immediately when it is changed without having to do
anything else. This may not be possible but it would be extremely helpful to
our sales staff.
|