Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Confused with If s and And s

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"",
"" "")))))"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Confused with If s and And s

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"",
"" "")))))"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Confused with If s and And s

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
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
confused in the o.c. cocomymy New Users to Excel 1 October 30th 08 10:42 PM
Confused Dale Excel Worksheet Functions 4 March 28th 07 02:52 AM
Confused Dale Excel Worksheet Functions 1 March 28th 07 12:21 AM
Confused Karmen New Users to Excel 4 February 24th 06 08:27 PM
I'm Confused........................................ Jonathan Excel Programming 8 May 4th 05 12:37 PM


All times are GMT +1. The time now is 06:28 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"