I have a table with columns A-H. Column H is sorted by fill color red (to top) first. Colum H is then sorted descending second. Column A is then sorted ascending last. My below code is working in this fashion but one thing is really annoying and would like it fixed. Anytime ANY cell is changed, the table refreshes to the top. I can be on row 200 and change a cell from 0 to 4 and it sends me to the top. I then have to scroll all the way down again. Can this be fixed? Any help would be greatly appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Cells(Rows.Count, 1).End(3).Row
With ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("H3:H" & LR), SortOn:=xlSortOnValues, Order:=xlDescending
.SortFields.Add Key:=Range("A3:A" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
.SetRange Range("A3:H" & LR)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
LR = Cells(Rows.Count, 1).End(3).Row
With ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("H3:H" & LR), SortOn:=xlSortOnValues, Order:=xlDescending
.SortFields.Add Key:=Range("A3:A" & LR), SortOn:=xlSortOnValues, Order:=xlAscending
.SetRange Range("A3:H" & LR)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub