- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Afternoon,
I did a little digging and here is the solution i found.
first ensure this reference file is checked. Located under the Tools menu bar in the VBA Editor See attached Image1_SortExcelRows & Image2_ExcelSortList_References_ScreenShot.
This will enable you to access the object library from Excel.
You where on the right track, please see the code below and let me know what you think. if this solves your issue please like the post and mark as a solution.
As always please reach out with further questions or concerns.
Sub SortExcelRange()
'set ref to workbook
Dim oWorkbook As Workbook
Set oWorkbook = GetObject("YOUR FILE PATH HERE WITH FILE NAME AND EXTENSION")
'set ref to active sheet
Dim oActiveSheet As WorkSheet
Set oActiveSheet = oWorkbook.Sheets.Item(1)
'adjust range as needed, i used b2 as the column to sort
oActiveSheet.Range("a1:c12").Sort Key1:=oActiveSheet.Range("b2"), order1:=xlAscending
End Sub