I have a table WITH a header row, which i would like to sort by ascending order based on the 1st column. The table can be of varying length but should be of fixed width / columns. I found this but it doesnt address my header and order criteria:
Xl := ComObjActive("Excel.Application")
xl.cells.sort(xl.columns(1), 1)
COM command to sort unknown table size in excel
-
- Posts: 16
- Joined: 04 Jul 2017, 19:49
Re: COM command to sort unknown table size in excel
Hi jimi_hendrix2017 , try this
Code: Select all
#SingleInstance force
#Persistent
xlByColumns := 2
xlPrevious := 2
xlAscending := 1
xlDescending := 2
xlHeaderYes := 1 ;Ignore Header
Return
#If WinActive("ahk_exe EXCEL.exe")
F1::
oExcel := ComObjActive("Excel.Application")
oSheet := oExcel.Worksheets(1)
oSheet.Select
oRange := "A1:" RegExReplace(oExcel.Sheets(1).Cells.Find("*", , , , xlByColumns, xlPrevious).Address,"\$")
oSheet.Range(oRange).Cells.Sort(oSheet.Columns(1), xlAscending , ComObjMissing(), , xlHeaderYes )
oSheet:=""
oExcel:=""
Msgbox DONE!!
Return
Donec Perficiam
-
- Posts: 16
- Joined: 04 Jul 2017, 19:49
Re: COM command to sort unknown table size in excel
@jmeneses Wow, I didnt even see this come in. Ironically I was seraching for the same thing and our old post came up!!. Unfortunately, its not quite working. It just blows right through and doesnt do anything, select the range or sort. Thoughts?