Trying to remove columns and sort a simple export and I'm getting an error:
Run-time error '9': Subscript out of range
every time I run the basic macro on a second recently created workbook.
Sub ONCE()
'
' ONCE Macro
' export and prep an ONC list
'
' Keyboard Shortcut: Ctrl+e
'
Range("A:A,B:B,F:F").Select
Range("F1").Activate
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").ColumnWidth = 8.29
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Columns("C:C").Select
ActiveWorkbook.Worksheets("QueueDetail_20160802_150124").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("QueueDetail_20160802_150124").Sort.SortFields.Add _
Key:=Range("C1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("QueueDetail_20160802_150124").Sort
.SetRange Range("A2:C35")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D4").Select
End Sub
The original workbook had 6 columns, all I did to record the macro was remove 3 of the extra columns, auto fit each column (double clicking so that each bit of information bellow fit visually), and then try to sort the workbook by the last column (smallest to largest).
When running the macro on a new workbook an error message is generated, and the sort doesn't run on the last column. Removing the extra columns and spacing seems to work flawlessly however.