 |

05-16-2004, 05:57 PM
|
|
Regular
|
|
Join Date: Mar 2004
Location: USA
Posts: 95
|
|
If statement or function?
|
I have a spreadsheet with 10 columns. In the 11th column I want the word error to appear if the data in any of the 10 columns is not a number, or is a number less than or equal to 0.
Would the best way to do this be to write a function for column 11, or use an if statement?
|
|

05-16-2004, 06:40 PM
|
|
Contributor
* Expert *
|
|
Join Date: Dec 2001
Posts: 725
|
|
|
Does it need to be done through code? You could enter a couple of if statements in a formula in column 11. If through code, then I would use a For/Next function for each column 1-10.
|
|

05-16-2004, 09:07 PM
|
 |
Sapience.Aquire
Super Moderator * Expert *
|
|
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,306
|
|
To do this with a cell equation you will need to use an array formula. Assuming the first 10 columns contain your data and they start at row 1 enter this equation into the formula bar while cell K1 is selected:
Code:
=IF(ISNUMBER(A1:J1),"","error")
Instead of hitting just 'Enter' hit Ctrl + Shift + Enter you should see in the formula bar squiggle brackets: {} around the above cell equation.
|
__________________
No the other right mouse click
|

05-17-2004, 05:59 PM
|
|
Regular
|
|
Join Date: Mar 2004
Location: USA
Posts: 95
|
|
|
Thank you both for your replies. I tried the iserror array formula and it didn't seem to work for me. Perhaps I was using it wrong. I am going to pose a different question to see if I can find out what I am looking for. Again thanks.
|
|

05-17-2004, 06:16 PM
|
 |
Unashamed geek
Retired Moderator * Expert *
|
|
Join Date: Jul 2003
Location: London, England
Posts: 8,988
|
|
|
Hmmm... the formula looks all right, but doesn't work for me either.
Here's a workaround... a bit of a kludge, but works. Again, Ctrl+Shift+Enter to enter it.
=IF(SUM(NOT(ISNUMBER(A1:J1))*1)>0,"error","ok")
|
|

05-17-2004, 08:13 PM
|
 |
Sapience.Aquire
Super Moderator * Expert *
|
|
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,306
|
|
Quote:
|
Originally Posted by Joe100
I tried the iserror array formula and it didn't seem to work for me.
|
Umm... what iserror formula?
That's weird, it works once or twice then stops working. Herilane's works fine though and still works even if it's not an array formula.  Still trying to wrap my head around why you would need to multiply 1  Last time I checked multiplying anything by 1 results in the same value. Thank you Microsoft!
|
__________________
No the other right mouse click
|

05-17-2004, 08:44 PM
|
 |
Microsoft Excel MVP
Forum Leader * Guru *
|
|
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
|
|
I'm not that great at this Array Formula stuff, but I'm sure Helen can clarify this tomorrow... but I do know why multiplying by 1 is necessary. It is because the =Sum() function cannot Sum boolean values such as 'True'. But you can coerce the value, using True * 1 = 1 and False * 1 = 0. (In VBA True * 1 = -1, so one has to be careful!  ) This "multiply by 1" technique is, more or less, the Excel Worksheet's method of effecting CLng(), if you will...
|
|

05-18-2004, 03:22 AM
|
 |
Down...
Retired Moderator * Expert *
|
|
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
|
|
An other formula way (not an array one) to achieve it...
Code:
=IF(OR(COUNTIF(A1:J1,"*")>0,COUNTIF(A1:J1,"<=0")>0),"ERROR","WHATEVER…")

|
Last edited by italkid; 05-18-2004 at 03:38 AM.
Reason: Misread the initial question...ooops
|

05-18-2004, 05:42 AM
|
|
Regular
|
|
Join Date: Mar 2004
Location: USA
Posts: 95
|
|
|
Thank you all. I haven't tried them yet but I feel sure that Herilane's and Talkids solutions will work. Thanks to Mike for telling us why you need to multiply by 1 in Herilane's formula. I was curious about that myself.
|
|

05-18-2004, 04:15 PM
|
 |
Sapience.Aquire
Super Moderator * Expert *
|
|
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,306
|
|
|
Thanks for that clarification Mike.
|
__________________
No the other right mouse click
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|