PC Review


Reply
Thread Tools Rate Thread

Confused with If s and And s

 
 
Pablo
Guest
Posts: n/a
 
      6th Apr 2009
I need some assistance with this formula below to make it easier to read and
functional. Everytime I start working on it something, in my head, tells me
it is not right. I started recording a macro and then added all the "Ands"
the formula because the recorder did not like them. What would be a way to
write this?

Range("B5").Select
ActiveCell.FormulaR1C1 = "=IF(Left(RC[4],2)= ""50"", RC[1],_
If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)= ""H""),""Harcourt K-6"",_
If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)<> ""H""),""Houghton
K-6"",_
If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)= ""H""),""HRW"",_
If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)<> ""H""),""McDougal"",
"" "")))))"
 
Reply With Quote
 
 
 
 
joel
Guest
Posts: n/a
 
      6th Apr 2009
I changed the nesting of the IF's to eliminate the AND's. The 4th and 5th
rows in the formula below need to be placed on the same line and the same
with 6th and 7th lines.

Range("B5").Select
ActiveCell.FormulaR1C1 = _
"=IF(LEFT(RC[4],2)= ""50"", RC[1]," & _
"IF(LEFT(RC[4],2)= ""30"",IF(MID(RC[4],7,1)= ""H"",""Harcourt
K-6"",""Houghton K-6"")," & _
"IF(LEFT(RC[4],2)= ""40"",IF(MID(RC[4],7,1)=""H"",""HRW"",
""McDougal""),"" "")))"

"Pablo" wrote:

> I need some assistance with this formula below to make it easier to read and
> functional. Everytime I start working on it something, in my head, tells me
> it is not right. I started recording a macro and then added all the "Ands"
> the formula because the recorder did not like them. What would be a way to
> write this?
>
> Range("B5").Select
> ActiveCell.FormulaR1C1 = "=IF(Left(RC[4],2)= ""50"", RC[1],_
> If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)= ""H""),""Harcourt K-6"",_
> If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)<> ""H""),""Houghton
> K-6"",_
> If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)= ""H""),""HRW"",_
> If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)<> ""H""),""McDougal"",
> "" "")))))"

 
Reply With Quote
 
Pablo
Guest
Posts: n/a
 
      6th Apr 2009
Perfect. Thanks.

"joel" wrote:

> I changed the nesting of the IF's to eliminate the AND's. The 4th and 5th
> rows in the formula below need to be placed on the same line and the same
> with 6th and 7th lines.
>
> Range("B5").Select
> ActiveCell.FormulaR1C1 = _
> "=IF(LEFT(RC[4],2)= ""50"", RC[1]," & _
> "IF(LEFT(RC[4],2)= ""30"",IF(MID(RC[4],7,1)= ""H"",""Harcourt
> K-6"",""Houghton K-6"")," & _
> "IF(LEFT(RC[4],2)= ""40"",IF(MID(RC[4],7,1)=""H"",""HRW"",
> ""McDougal""),"" "")))"
>
> "Pablo" wrote:
>
> > I need some assistance with this formula below to make it easier to read and
> > functional. Everytime I start working on it something, in my head, tells me
> > it is not right. I started recording a macro and then added all the "Ands"
> > the formula because the recorder did not like them. What would be a way to
> > write this?
> >
> > Range("B5").Select
> > ActiveCell.FormulaR1C1 = "=IF(Left(RC[4],2)= ""50"", RC[1],_
> > If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)= ""H""),""Harcourt K-6"",_
> > If(And(Left(RC[4],2)= ""30"", Mid(RC[4],7,1)<> ""H""),""Houghton
> > K-6"",_
> > If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)= ""H""),""HRW"",_
> > If(And(Left(RC[4],2)= ""40"", Mid(RC[4],7,1)<> ""H""),""McDougal"",
> > "" "")))))"

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confused Newbie - Very Confused:( Wizard Microsoft Access Forms 0 20th Oct 2005 10:37 AM
Confused! Kevin M Asus Motherboards 1 16th Aug 2005 05:24 PM
Confused =?Utf-8?B?QmxpbmU=?= Microsoft Access 1 5th Aug 2005 05:31 PM
Confused Steven Ridley Microsoft Outlook 1 18th Apr 2004 06:26 AM
Confused, need valid logon for OE, confused.. Rob Windows XP General 1 3rd Nov 2003 02:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 AM.