Hi tmplinshi,
I'm trying to convert the following VBA to AHK:
Code: Select all
lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
col = ActiveCell.Column
Range(ActiveCell, Cells(lastRow, col)).Select
n = Application.CountA(Selection) 'Non-Blank cells in the selection
The use of
xlCellTypeLastCell resulted in finding this thread...great stuff! I'll be putting
xlFindLastCell in my bag-of-tricks!
I know that this question is not exactly related to
xlFindLastCell, but it uses the same basic COM Excel features, so I'm hoping that you can help. I converted the first three VBA lines as follows (thanks for the
xlCellTypeLastCell enumeration):
Code: Select all
xlCellTypeLastCell:=11 ; enumeration
xl:=ComObjActive("Excel.Application")
lastRow:=xl.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
col:=xl.ActiveCell.Column
ActiveCellAddress:=xl.ActiveCell.Address[0,0]
ActiveRange:=xl.Cells(lastRow,col)
Selection:=xl.Range(ActiveCellAddress,ActiveRange).Select
A
MsgBox shows that
lastRow and
col are correct. Also, the range of cells is properly selected in Excel. However, I'm stuck on the last VBA line, as it's not clear to me what
Selection needs to be in AHK for the
CountA method. I thought that it would be the value that I assigned to it in the last line posted above, but that doesn't work —
n always come back as
1 with this:
Thanks for your help. Regards, Joe
Edit on 18-Jan-2020: For others following this thread, the answer to my question is here:
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=71711&p=310222#p310222
Regards, Joe