Re: If statements in Excel
Re: If statements in Excel
- Subject: Re: If statements in Excel
- From: Stan Cleveland <email@hidden>
- Date: Wed, 28 Nov 2007 12:22:15 -0800
- Thread-topic: If statements in Excel
On 11/28/07 11:05 AM, Justin Laden wrote:
> I'm having difficulty with if statements in Excel; I'm trying to go through
> every cell in a range (one column in my table), and based on the value of a
> cell, I want to fill another cell in another column with a value. For some
> reason, my code for this action does nothing. Here's what I have so far.
>
> repeat with i from 1 to (count cells of range ("F2:F" & z ))
> set targetCell to (cell i of range ("I2:I" & z))
> if value of cell ("F" & i) = "Printed" then
> set value of targetCell to {"OK"}
> else
> exit repeat
> end if
> end repeat
Kurt¹s last suggestion is the ultimate of simplicity and certainly worth
considering. However, in looking further at the problem from an AppleScript
point of view, there are several possible reasons why your script "does
nothing."
1. Unless the first cell in the range has a value of "Printed", the repeat
loop is immediately exited.
2. Numeric variables are being used in two different ways:
z as an index to cells in the ranges F2:Fz and I2:Iz
i to specify a specific row in the cell Fi
When their values are 1, they are meant to refer to cells F2 and I2 in
the case of i, but refer to cell F1 in the case of z.
3. The code 'cell i of range ("I2:I" & z)' generates a nonsensical reference
that refers to nothing (range "$I$2" of range "I2:I5" of application
"Microsoft Excel") when using values i=1 and z=5. You can't set the
value of a nonexistent cell to "OK".
Getting the logic right for something like this can be a challenge, indeed.
Maybe these observations will give you some help.
Stan C.
_______________________________________________
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