I am having trouble with a macro code that is run from access onto a worksheet in Excel. The part I'm having trouble with is when I try to apply a sort. I get a runtime 91 error. SRange does work to select the right area. the error comes on the sort
PHP:
Set xlapp = CreateObject("Excel.Application")
xlapp.Application.Visible = True
Set xlwkb = xlapp.Workbooks.Open(sfile)
*****************lots of Macro code that already works is here*******
xlapp.ActiveSheet.Range(SRange).Select
xlapp.Selection.Sort Key1:=ActiveSheet.Range("H1"), _
Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
*****************more Macro code that already works is here*******