Hi All,
I have two worksheets named "Data" and "Product". I want to use the following macro to sort the records depending which sheet is active. If I am in the "Data" sheet, it does the sort in the "Product" sheet? I was expecting it to ignore the second IF statement when I am in the "Data" sheet? Please help.
Sub RegionSort()
' Sort by Region
Application.ScreenUpdating = False
If Worksheets("Data").Visible Then
Application.Goto Reference:="Data"
End If
If Worksheets("Product").Visible Then
Application.Goto Reference:="Data2"
End If
Selection.Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A4").Select
Application.ScreenUpdating = True
End Sub
Thank You
Bookmarks