Reply to topic  [ 14 posts ] 
Excel help 
Author Message
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
I'm trying to combine two formulas without success, can anyone help?

=IsNumber(B6)
=IF(C6=$B6,1,0)

What I'm wanting Excel to do is:
Is there a number in B6? If not, leave cell blank, if there is do the following equation:
If C6 is the same as B6, then the cell value should be 1, if it isn't, the cell value should be 0.

How do I get that to work? I've tried google, but I can't seem to find a way to combine the IsNumber and IF functions.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Mon May 23, 2011 9:07 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
l3v1ck wrote:
I'm trying to combine two formulas without success, can anyone help?

=IsNumber(B6)
=IF(C6=$B6,1,0)

What I'm wanting Excel to do is:
Is there a number in B6? If not, leave cell blank, if there is do the following equation:
If C6 is the same as B6, then the cell value should be 1, if it isn't, the cell value should be 0.

How do I get that to work? I've tried google, but I can't seem to find a way to combine the IsNumber and IF functions.

Yup there is but I'm not sure I fully understand the problem.

Ah, ok... re-read.

=IF(IsNumber(B6), if(C6 = B6, 1, 0), "")

That should work.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon May 23, 2011 9:12 pm
Profile WWW
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
Thanks
I'll give it a try.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Mon May 23, 2011 9:14 pm
Profile WWW
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
Tried it with and without the spaces inbetween characters, but the result is always blank.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Mon May 23, 2011 9:18 pm
Profile WWW
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
Ah. Your formula does work if the inputs are numbers. My inputs in B6 and C6 are letters.
If the letters match I want it to put a 1 as teh cell value and a 0 if the don't.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Mon May 23, 2011 9:21 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
l3v1ck wrote:
Ah. Your formula does work if the inputs are numbers. My inputs in B6 and C6 are letters.
If the letters match I want it to put a 1 as teh cell value and a 0 if the don't.

Ah OK, this is opposite to your description though...

Quote:
Is there a number in B6? If not, leave cell blank, if there is do the following equation:
If C6 is the same as B6, then the cell value should be 1, if it isn't, the cell value should be 0.


If you want the comparison only to be with letters then...

=IF(NOT(ISNUMBER(B5)), IF(C5=B5,1,0), "")

This will only put a 1 or a 0 if there is a letter in B5. If the value in B5 is a number then the result will be blank.

I'm not sure this does what you want though.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon May 23, 2011 9:26 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Jun 18, 2009 5:10 pm
Posts: 5836
Reply with quote
Fogmeister wrote:
=IF(NOT(ISNUMBER(B5)), IF(C5=B5,1,0), "")

This will only put a 1 or a 0 if there is a letter in B5. If the value in B5 is a number then the result will be blank.

I'm not sure this does what you want though.

Looks right to me...

...but I'm using LibreOffice so I daredn't test it.

_________________
Jim

Image


Mon May 23, 2011 10:41 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
rustybucket wrote:
Fogmeister wrote:
=IF(NOT(ISNUMBER(B5)), IF(C5=B5,1,0), "")

This will only put a 1 or a 0 if there is a letter in B5. If the value in B5 is a number then the result will be blank.

I'm not sure this does what you want though.

Looks right to me...

...but I'm using LibreOffice so I daredn't test it.

Lol, I was using libre office also :-)

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Tue May 24, 2011 6:34 am
Profile WWW
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
Fogmeister wrote:
=IF(IsNumber(B6), if(C6 = B6, 1, 0), "")
The formula seems fine. If I enter numbers in C5 and B5, it works exactly as it's supposed to.
The problem I have now is that my inputs in C5 and B5 are letters. Excel seems to decide that it doesn't want to do the calculation if that's the case. Stupid bloody MS.

I was a bit cheecky and tried: =IF(IsLetter(B6), if(C6 = B6, 1, 0), ""). Excel wasn't having any of it though.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Tue May 24, 2011 6:44 am
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 6:44 pm
Posts: 4141
Location: Exeter
Reply with quote
Well use ISBLANK instead of ISNUMBER. If you need to distinguish between the two you're going to need to use nested IF statements

Edit: There is one minor caveat, in that if you have an IF statement or similar that puts the contents of "" into a cell, it will always fail an ISBLANK test.

_________________
"The woman is a riddle inside a mystery wrapped in an enigma I've had sex with."


Tue May 24, 2011 6:45 am
Profile WWW
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
I'm still not getting a result if I use that, but have letters as the inputs in cells B5 and C5. Stupid bloody Excel.

I could try using Excel 2007 on my PC rather than Excel 2007 on my laptop. But even if it works on 2007 it's pointless. People who I'm sending it to don't all use 2007.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Tue May 24, 2011 6:53 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
OK, I'm at work now with proper Excel in front of me.

Could you explain again exactly what it is that you want the formula to do?

I'll have another go.

The first explanation said that it only wants to display 1 or 0 if B6 was a number but this seems to be not what you meant.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Tue May 24, 2011 7:55 am
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
Code:
=if(isblank(b6),"Error",if(c6=b6,1,0))

Remove "Error" and replace it with "", once you have finished debugging.

Or, if you are checking for not a number:

Code:
=if(or(isblank(b6),isnumber(b6)),"Error",if(c6=b6,1,0))


Always test a positive first, even if the result you are after is not the positive, as checking for positives is much more efficient than searching for negatives. In Excel, you have to give actions for both true and false, so it doesn't make much difference to the formula. The "NOT" operative takes an extra couple of clock cycles to calculate, which isn't much nowadays and you won't notice any difference on one formula, but if that is spread over thousands of rows, it can make a huge difference! So it is something you should try and keep in mind, when writing formula.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Tue May 24, 2011 8:06 am
Profile ICQ
What's a life?
User avatar

Joined: Fri Apr 24, 2009 10:21 am
Posts: 12700
Location: The Right Side of the Pennines (metaphorically & geographically)
Reply with quote
big_D wrote:
Or, if you are checking for not a number:

Code:
=if(or(isblank(b6),isnumber(b6)),"Error",if(c6=b6,1,0))


Thanks. That seems to work.

Thanks for all the suggestions guys.

_________________
pcernie wrote:
'I'm going to snort this off your arse - for the benefit of government statistics, of course.'


Tue May 24, 2011 8:50 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.