I am trying to sort column A in ascending order if a cell in column J or K is changed. The tricky part is that I want the code to look at column K first. If nothing is changed in that column, then look at column J for a change, which will always happen. The reason I want to do this is that I want the code to wait to run the sort function until after all information has been entered into that row first so that it isn't sorting too soon and I have to go looking for the row to continue to enter more data. Column K, however, doesn't always have a change like column J does. In that case, it can sort after I've changed the content in column J; otherwise, sort after entering data into column K. I hope this makes sense. Below is the code I thought would work, but it doesn't. After more thought, I realized that it probably doesn't work because it looks at column K first, but if after looking at column K and it didn't change, no new data is entered into column J to trigger the sort function. Am I right in this thought process? I don't know how else to code this, though.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("k:k")) Is Nothing Then
Range("a1").Sort Key1:=Range("a2"), \_
Order1:=xlAscending, Header:=xlYes, \_
OrderCustom:=1, MatchCase:=False, \_
Orientation:=xlTopToBottom
ElseIf Not Intersect(Target, Range("j:j")) Is Nothing Then
Range("a1").Sort Key1:=Range("a2"), \_
Order1:=xlAscending, Header:=xlYes, \_
OrderCustom:=1, MatchCase:=False, \_
Orientation:=xlTopToBottom
End If
End Sub