I have an excel report that is generated in another program every week. The report is not sorted by date and it may have 100 rows of data one week and 200 rows of data another week. My excel file has formulas that refer to this original report. I need those formulas to update first, then I need the information to automatically sort by date (column D in my excel file) and item (column c). I have tried to setup a script to run, but it's not working. Here's the script:
I have a sample, but apparently don't have attachment priveleges... If you want the sample, check here:
Autosort by date AFTER formulas are updated
Code:
Option Explicit
Private Sub Workbook_Open()
SortOnEntry
End Sub
Sub SortOnEntry()
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End Sub
I have a sample, but apparently don't have attachment priveleges... If you want the sample, check here:
Autosort by date AFTER formulas are updated