Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ck ck is offline
external usenet poster
 
Posts: 52
Default Help with if statement

I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Help with if statement

It looks like it's returning the correct result to me.
The string "10 years, 11months" satisfies the
AND(E203"0years,6months",E203<="2years,0months") condition, because the
first digit 1 is greater than 0 and is less than 2.
Perhaps you've forgotten that you are comparing text strings, not comparing
numbers?
--
David Biddulph


"ck" wrote in message
...
I have used the following statement, but it is returning an incorrect
result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also
does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default Help with if statement

ck wrote:
I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))


What is in E203?
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Help with if statement

ck, I played with your formula and found that if you use 00years,00months --
create the accepability of a double digit number -- which you will have since
the months in a year may be a single or a double digit number (0, 1, 2, . . .
9, 10, 11). Just change the formula to read:

=IF(AND(E203="00years,00months",E203<="00years,03 months"),"0-3",IF(AND(E203"00years,03months",E203<="00years,0 6months"),"3-6",IF(AND(E203"00years,06months",E203<="02years,0 0months"),"6m
- 2y",IF(AND(E203"02years,00months",E203<="99years, 00months"),"Older than
2",""))))


"ck" wrote:

I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ck ck is offline
external usenet poster
 
Posts: 52
Default Help with if statement

e203 contains the age calculated in years and months by using the following
formula: =DATEDIF(D203,B203,"y")&"years,"&DATEDIF(D203,B203 ,"ym")&"months"

"Glenn" wrote:

ck wrote:
I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))


What is in E203?
.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ck ck is offline
external usenet poster
 
Posts: 52
Default Help with if statement

I changed the formula and I am still getting errors...Do I need to change
anything to create the acceptability of a double digit number?

"nita" wrote:

ck, I played with your formula and found that if you use 00years,00months --
create the accepability of a double digit number -- which you will have since
the months in a year may be a single or a double digit number (0, 1, 2, . . .
9, 10, 11). Just change the formula to read:

=IF(AND(E203="00years,00months",E203<="00years,03 months"),"0-3",IF(AND(E203"00years,03months",E203<="00years,0 6months"),"3-6",IF(AND(E203"00years,06months",E203<="02years,0 0months"),"6m
- 2y",IF(AND(E203"02years,00months",E203<="99years, 00months"),"Older than
2",""))))


"ck" wrote:

I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default Help with if statement

OK, so E203 contains TEXT. Try this instead:

=IF(DATEDIF(D203,B203,"M")<3,"0-3",IF(DATEDIF(D203,B203,"M")<6,"3-6",
IF(DATEDIF(D203,B203,"M")<24,"6m - 2Y","Older than 2")))



ck wrote:
e203 contains the age calculated in years and months by using the following
formula: =DATEDIF(D203,B203,"y")&"years,"&DATEDIF(D203,B203 ,"ym")&"months"

"Glenn" wrote:

ck wrote:
I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))

What is in E203?
.

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Help with if statement

Did you remember to change your E203 formula to give 2 digits for years and
months? Does your formula look like:
=TEXT(DATEDIF(D203,B203,"y"),"00")&"years,"&TEXT(D ATEDIF(D203,B203,"ym"),"00")&"months"
?
--
David Biddulph


"ck" wrote in message
...
I changed the formula and I am still getting errors...Do I need to change
anything to create the acceptability of a double digit number?

"nita" wrote:

ck, I played with your formula and found that if you use
00years,00months --
create the accepability of a double digit number -- which you will have
since
the months in a year may be a single or a double digit number (0, 1, 2, .
. .
9, 10, 11). Just change the formula to read:

=IF(AND(E203="00years,00months",E203<="00years,03 months"),"0-3",IF(AND(E203"00years,03months",E203<="00years,0 6months"),"3-6",IF(AND(E203"00years,06months",E203<="02years,0 0months"),"6m
- 2y",IF(AND(E203"02years,00months",E203<="99years, 00months"),"Older
than
2",""))))


"ck" wrote:

I have used the following statement, but it is returning an incorrect
result
for some cells. In an cell containing an age of 10 years,
11months..the
formula is returning "6m-2y" when it should say older than 2. It also
does
this for the age 25 years 6 months and 18 years 10 months. Please
help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ck ck is offline
external usenet poster
 
Posts: 52
Default Help with if statement

You are a genious! Thank you! Thank you!

"Glenn" wrote:

OK, so E203 contains TEXT. Try this instead:

=IF(DATEDIF(D203,B203,"M")<3,"0-3",IF(DATEDIF(D203,B203,"M")<6,"3-6",
IF(DATEDIF(D203,B203,"M")<24,"6m - 2Y","Older than 2")))



ck wrote:
e203 contains the age calculated in years and months by using the following
formula: =DATEDIF(D203,B203,"y")&"years,"&DATEDIF(D203,B203 ,"ym")&"months"

"Glenn" wrote:

ck wrote:
I have used the following statement, but it is returning an incorrect result
for some cells. In an cell containing an age of 10 years, 11months..the
formula is returning "6m-2y" when it should say older than 2. It also does
this for the age 25 years 6 months and 18 years 10 months. Please help.

=IF(AND(E203="0years,0months",E203<="0years,3mont hs"),"0-3",IF(AND(E203"0years,3months",E203<="0years,6mon ths"),"3-6",IF(AND(E203"0years,6months",E203<="2years,0mon ths"),"6m
- 2y",IF(AND(E203"2years,0months",E203<="99years,0m onths"),"Older than
2",""))))
What is in E203?
.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
If statement or lookup statement not sure Renegade40 Excel Worksheet Functions 2 January 18th 09 06:11 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"