willie108
asked on
Runtime Error and macro setting "use relative references"
Hi. I was recording a macro and using the "use relative references" setting. I tried doing a sort with this setting but get a runtime error which highlights this code
.SetRange ActiveCell.Offset(-1, 0).Range("A1:G3846")
any ideas about this?
.SetRange ActiveCell.Offset(-1, 0).Range("A1:G3846")
any ideas about this?
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("perStockTweets").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("perStockTweets").Sort.SortFields.Add Key:= _
ActiveCell.Offset(0, 1).Range("A1:A3845"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("perStockTweets").Sort
.SetRange ActiveCell.Offset(-1, 0).Range("A1:G3846")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, I said pivot table in one of the messages above but I am trying to sort
Try this workbook. Paste the data and corresponding headers then run the macro.
Sort.xlsm
Sort.xlsm
ASKER
Thanks.
ASKER
Open in new window