Is there anyway to modify this script to only adjust the columns within checking every cell? (e.g. if I have A1:F15 selected, it will adjust only columns A through F if they are not hidden. The script currently does this, but it will cycle through each cell from A1 to F15 instead of each column)
Code: Select all
+Right::
If WinActive("ahk_class XLMAIN")
{
oExcel := ComObjActive("Excel.Application")
;ComObjActive("Excel.Application").Cells.Columns.AutoFit ;AutoFit all columns
for c in oExcel.selection
if !(c.EntireColumn.Hidden)
c.EntireColumn.AutoFit
}
return
}
else
Send {Shift down}{End}{shift up}
return