• 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: Excel scripting question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Excel scripting question


  • Subject: Re: Excel scripting question
  • From: john terranova <email@hidden>
  • Date: Sun, 08 Apr 2001 18:02:38 -0700

on 4/8/01 3:05 PM, cheri at email@hidden wrote:

> Does anyone know the excel syntax for indicating
> the next cell directly below another cell?
...
> property microspot : "Microspot Raster"
> property laserwriter8 : "LaserWriter 8"
> property adobeps : "AdobePS"
> property epson : "SC 3000(AT)"
>
> tell application "Microsoft Excel"
> Activate
>
> if (Value of Range "R2C2" is laserwriter8) then
> set Value of Range "R2C5" to ".09"
> end if
> if (Value of Range "R2C2" is adobeps) then
> set Value of Range "R2C5" to " .09"
> end if
> if (Value of Range "R2C2" is epson) then
> set Value of Range "R2C5" to "6.00"
> end if
> if (Value of Range "R2C2" contains phaser) then
> set Value of Range "R2C5" to " 6.00"
> end if
> end tell

You can loop through cells of a column (or row to go across). I would do
something like this (not tested and watch the line breaks):

tell application "Microsoft Excel"

repeat with rw from 2 to 202 -- what ever the last row is

-- save the value in a local variable so you don't have to
-- ask XL for it a bunch of times

set val to value of cell rw of column 2 -- of sheet "foo" of workbook 1

if (val is laserwriter8 or val is adobeps) then

-- you can use the number .09 instead of the string, if you want
set val5 to ".09"

else if (val is epson or val contains "phaser") then

set val5 to "6.00"

end if

set cell rw of column 5 to val5

end repeat

end tell

N.B. This will act on the active sheet of the active workbook. You can
specify non-active sheets and workbooks by name or number, as in the
comment.

--
john terranova, email@hidden

"I was embarrassed every time George Bush opened his mouth."
-- a Texas viewer of the third presidential debate


References: 
 >Excel scripting question (From: cheri <email@hidden>)

  • Prev by Date: Re: Excel scripting question
  • Next by Date: Re: Excel scripting question
  • Previous by thread: Re: Excel scripting question
  • Next by thread: Re: Excel scripting question
  • Index(es):
    • Date
    • Thread