I am trying to translate my visual basic to Applescript with Excel 2008.
I use very often
where myrow1,myrow2,mycol1,mycol2 are numbers passed through the subroutine.
How can I write that in applescript? All I have seen is range (“B2:C12”) with letters designing the column.
As I am not yet ready for shortcuts ;), I wrote it a way that is more understandable for me.:
set myrow1 to 2 set mycol1 to 4 set myrow2 to 10 set mycol2 to 6 tell application "Microsoft Excel" set firstcel to (get address of cell mycol1 of row myrow1 of active sheet) set lastcel to (get address of cell mycol2 of row myrow2 of active sheet) set myrange to range (firstcel & ":" & lastcel) select myrange end tell
Excel X (10.1.5), oddly, was straightforward to convert from VB:
set currentRow to "2" set currentColumn to "1" set currentCell to ("R" & currentRow & "C" & currentColumn) as text Select Range currentCell
(selects the cell in Column 1, Row 2)
In other words, I just manually created the selection string “R1C2” syntax.
Selecting a range works the same way:
Select Range ("R" & currentRow & "C1:R" & currentRow & "C4")
(select the range R1C1 through R1C4, aka R1C1:R1R4)
The script does not work with Excel 2008 (v12.xx) nor Excel 2004 (v11.xx).