• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Filling a cell in Excel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filling a cell in Excel


  • Subject: Re: Filling a cell in Excel
  • From: Scott Babcock <email@hidden>
  • Date: Wed, 02 Jun 2004 16:11:26 -0700

Remember - You don't need to use the selection to reference cells. You can
refer to them directly:

tell application "Microsoft Excel"
set value of range "A1" to "asdfa"
set x to value of range "A1"
end tell

You can also set the values of a range of cells with a list:

tell application "Microsoft Excel"
set value of range "A1:C3" to {,
{"A1", "B1", "C1"}, ,
{"A2", "B2", "C2"}, ,
{"A3", "B3", "C3"}}
end tell

You can even fill multiple noncontiguous ranges from one list:

tell application "Microsoft Excel"
set listSep to get international entry index list separator
set value of range ("A1:C3" & listSep & "D4:D6") to {,
{"A1", "B1", "C1"}, ,
{"A2", "B2", "C2"}, ,
{"A3", "B3", "C3"}}
end tell

Play around with this... You'll be amazed at what you can do in Excel
AppleScript that was much more difficult in VBA.

Also, if you must use R1C1 notation (the 'consolidate' event requires it),
use the 'get international' event to get the local characters for 'R' and
'C'. That way, your scripts will run correctly regardless of which locale
you're in. Here's a handler that returns the local R1C1 string for a given
row/column coordinate:

on MakeR1C1(row, column)
tell application "Microsoft Excel"
set _row_ to get international entry index upper case row letter
set _col_ to get international entry index upper case column letter
end tell
set strR1C1 to _row_ & (row as text) & _col_ & (column as text)
return strR1C1
end MakeR1C1

The 'get international' event is indispensable if you write scripts that
have to work in several locales. It supplies locale-specific information for
things like decimal separator, date order, and local currency symbol. (If
you look back at my third example, you'll see that I use 'get international'
to get the local list separator.)

- Scott Babcock

-----Original Message-----
Date: Fri, 28 May 2004 10:40:38 -0400
Subject: Re: Filling a cell in Excel
From: "Rebecca O'Connell" <email@hidden>
To: AppleScript Users <email@hidden>

For the first line I got "Can't set..."
For the second line I got missing value for z

Turns out the correct answer is...
tell application "Microsoft Excel"

set value of selection to "asdfg"
set x to value of selection
end tell

Note: If you have one cell selected, that one cell will be set to "asdfg"
and x will be "asdfg". If you have two cells selected, both cells selected
will be set to "asdfg" and x will be {{"asdfg", "asdfg"}}.

It wasn't working before because I needed to restart Smile and/or Excel.

Thanks your help,
Rebecca

On 5/27/04 10:50 PM, "trinko" <email@hidden> wrote:

> set the value of the first cell in the selection of window 1 to 19
> set z to the value of the first cell in the selection of window 1

Sent using the Microsoft Entourage 2004 for Mac Test Drive.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Need help in gui scripting
  • Next by Date: Re: open location not working
  • Previous by thread: Re: iTunes Picture data
  • Next by thread: Re: Filling a cell in Excel
  • Index(es):
    • Date
    • Thread