Hi all,
I am still fairly new to VBA and have in issue I can not solve. Is there a way to set the focus on a range of cells and have a fuction, like sort, happen without actually selecting that range? I want my macro to run in the background without disturbing what I am doing on my other open spreadsheets. Currently if the wookbook is not open, I get an error, also I want the sort to happen without the screen flashing at me. Here is my code:
Sub Auto_Sort()
'
' Auto_Sort Macro
'
Range("A50:C83").Select
ThisWorkbook.Worksheets("Dashboard").Sort.SortFields.Clear
ThisWorkbook.Worksheets("Dashboard").Sort.SortFields.Add Key:=Range( _
"C50:C83"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ThisWorkbook.Worksheets("Dashboard").Sort
.SetRange Range("A50:C83")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Reset Auto_Sort counter
Application.OnTime Now + TimeValue("00:00:30"), "Auto_sort"
End Sub
Hope I did that right!
All help is appreciated!
Bookmarks