Re: R1C1
Re: R1C1
- Subject: Re: R1C1
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 14 Jul 2009 10:34:32 -0400
I don't know about scripting Excel (what version? when did R1C1
notation go away?) but surely there must be functions in Excel for
converting between text column labels and the corresponding numeric
indices??
If not, they're not hard to write, but it seems kinda silly to have to
do so when you're talking to a spreadsheet program!
Example (requires Leopard):
property capitalA: id of "A"
property capitalZ: id of "Z"
property lowercaseA: id of "a"
property lowercaseZ: id of "z"
to columnIndex from columnLabel
set returnValue to 0
repeat with ch in columnLabel
set ord to id of ch
if ord >= capitalA and ord <= capitalZ
set value to ord - capitalA + 1
else if ord >= lowercaseA and ord <= lowercaseZ
set value to ord - lowercaseA + 1
else
error "Illegal character '" & ch & "' in column columnLabel"
end if
set returnValue to ( returnValue ) * 26 + value
end repeat
return returnValue
end columnIndex
to columnLabel from columnIndex
set returnValue to ""
repeat while columnIndex > 0
set value to (columnIndex - 1) mod 26 + 1
set columnIndex to (columnIndex - 1) div 26
set returnValue to character id (capitalA + value - 1) & returnValue
end repeat
return returnValue
end columnLabel
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >R1C1 (From: Frank Renner <email@hidden>) |