I have the following macro, works great in my sheet, but you may notice that it hides certain rows based on a calculated value, the problem is that the selected cells after the macro is executed are the hidden or the displayed cells, I don't want this to hapen, I want the selecte cell to be the one that I'm changing, not to jump to the hidden rows... hope you got me
Private Sub Worksheet_Calculate()
If Range("L73").Value > Range("o55").Value Then
Application.EnableEvents = False
With Range("AI3:AI72")
.Value = Range("AF3:AF72").Value
.Sort Key1:=Range("AI3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = False
Application.EnableEvents = True
Else
Application.EnableEvents = False
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = True
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Calculate()
If Range("L73").Value > Range("o55").Value Then
Application.EnableEvents = False
With Range("AI3:AI72")
.Value = Range("AF3:AF72").Value
.Sort Key1:=Range("AI3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = False
Application.EnableEvents = True
Else
Application.EnableEvents = False
Sheets("DM1").Rows("75:85").Select
Selection.EntireRow.Hidden = True
Application.EnableEvents = True
End If
End Sub