Excel COM: Column to the Right of Arbitrary Column Topic is solved
Excel COM: Column to the Right of Arbitrary Column
Situation: I have a piece of data in a given column. The column might be one letter, or it might be two letters. I need to retrieve the data one column to the right. I'm at a bit of a loss. Next row is easy; just add one to the variable. But I can't seem to figure out next column.
Re: Excel COM: Column to the Right of Arbitrary Column Topic is solved
You can use .Offset (https://msdn.microsoft.com/en-us/vba/ex ... erty-excel) or .Cells (https://msdn.microsoft.com/en-us/vba/ex ... erty-excel or https://msdn.microsoft.com/en-us/vba/ex ... erty-excel).
Simple example using the active cell. Excel must be running when you start the script then press Ctrl+1, 2 or 3.
Simple example using the active cell. Excel must be running when you start the script then press Ctrl+1, 2 or 3.
Code: Select all
XL := ComObjActive("Excel.Application")
return
^1::
MsgBox % XL.ActiveCell.Row "`n" XL.ActiveCell.Column
return
^2::
Row := XL.ActiveCell.Row
Col := XL.ActiveCell.Column
Cell := XL.Cells(Row + 2, Col + 3)
MsgBox % Cell.Address
return
^3::
MsgBox % XL.ActiveCell.Offset(2, 3).Address
return
Who is online
Users browsing this forum: No registered users and 188 guests