How to get column or row number of active cell

A

Apis mellifera

Can anyone tell me how to return the row or column index of the active cell
to a variable in AppleScript? I imagine it would look something like this:

set <variable> to first column index of active cell

But this doesn't work. Thanks
 
J

JE McGimpsey

Apis mellifera said:
Can anyone tell me how to return the row or column index of the active cell
to a variable in AppleScript? I imagine it would look something like this:

set <variable> to first column index of active cell

But this doesn't work. Thanks

One way:

set a to (get first column index of active cell)
 
J

Jamie

JE McGimpsey said:
set a to (get first column index of active cell)

How can I get the same thing but for a row? Would this work?

set a to (get first row index of active cell)
 
J

JE McGimpsey

Jamie said:
How can I get the same thing but for a row? Would this work?

set a to (get first row index of active cell)

Hmmm...

what happens when you try it?
 
J

Jamie

It doesn't seem to work.

I was trying to use the same concept to get the address information from a
cell divided into column and row information. Here's a snippit of my code
that I've put into a small script to debug. I've tried a whole bunch of
different things and trying to get the dialog to print either mycol2 or
myrow2's addresses fails...

tell application "Microsoft Excel"
activate object worksheet "Sheet1"

(* find first occurance of the word map and call this cell nextmap *)
set nextmap to (find (range "A:A" of worksheet "Sheet1") what "Map")

(*set myrow2 and mycol2 to values take from nextmap address*)
set myrow2 to (get address of row nextmap of Sheet1)
set mycol2 to (get first column index of cell nextmap of Sheet1)
display dialog "myrow2 is set to" & (get address myrow2)

end tell
 
J

Jamie

I figured it out. I mixed and match code when really I just need to use your
first suggestion.


(* find first occurance of the word map and call this cell nextmap *)
set nextmap to (find (range "A:A" of worksheet "Sheet1") what "Map")
get address nextmap

set mycol2 to first column index of nextmap
set myrow2 to first row index of nextmap
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top