automatic data sorting?
RYGUY! I right click on the sheet but all I get is a drop down menu. No
window to post any code. What am I missing?
??????????
"ryguy7272" wrote:
This is an auto-sort issue, which is easily remedied with this macro:
Right-click on the sheet that you want to auto-sort data on and then paste
this code into the window that opens:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim EndData As Long
If Target.Column 2 Then Exit Sub
Application.ScreenUpdating = False
EndData = Cells(Rows.Count, 1).End(xlUp).Row
With Range(Cells(2, 1), Cells(EndData, 2))
.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
Application.ScreenUpdating = False
End Sub
Notice, you are going to sort based on the values in Colun B, and the sort
starts in row 2. You will, almost certainly, need to make a few small
modifications to the code; change this:
Range("B2")
to suit your needs.
Regards,
Ryan---
--
RyGuy
"Patrick" wrote:
I have a spreadsheet where entries are made by date. Occasionally, I have to
add an entry that I overlooked for a previous date. Then I usually highlight
everything and have Excel sort to put things in the right order. My question
is whether I can tell Excel that if I enter a date that is earlier in the
column than a previous date it should automatically sort and put things in
order for me.
|