Skip navigation

If Then statement to write text in cell

1256 Views 26 Replies Latest reply: Feb 6, 2013 2:48 PM by nandi RSS
1 2 Previous Next
nandi Level 1 Level 1 (15 points)
Currently Being Moderated
Feb 1, 2013 9:48 AM

I need a function to say

 

IF((B3>B2::THEN Write in B4"Some text")ELSE Write"Another text"))

 

eg

if 5 (B3) is greater than 3 (B2), write this text in B4 "Some text"

else write "Another text"

 

 

Part 2

A second action is required once the above is completed.

If A(then copy cell data from C1 into D10)(ELSE(copy cell data of D1 into D10))

 

eg.

IF((A is true copy the the "C1 Contents" into D10)(Else copy "D1 Contents" into D10))

MacBook Pro, Mac OS X (10.7.4), bought in 2012
  • Jerrold Green1 Level 7 Level 7 (28,120 points)
    Currently Being Moderated
    Feb 1, 2013 10:17 AM (in response to nandi)

    nandi wrote:

     

    I need a function to say

     

    IF((B3>B2::THEN Write in B4"Some text")ELSE Write"Another text"))

     

    eg

    if 5 (B3) is greater than 3 (B2), write this text in B4 "Some text"

    else write "Another text"

     

     

    Part 2

    A second action is required once the above is completed.

    If A(then copy cell data from C1 into D10)(ELSE(copy cell data of D1 into D10))

     

    eg.

    IF((A is true copy the the "C1 Contents" into D10)(Else copy "D1 Contents" into D10))

    The syntax for IF is:

     

    IF(if-expression, if-true, if-false)

     

    Just replace ::Then, and ELSE Write with commas and you have it.

     

    Remember, if you want to control what is in B4, you write the expression in B4. It's a Pull concept, not a Push concept. Fetch rather than Put, if you prefer. So your action If A(then copy cell data from C1 into D10)(ELSE(copy cell data of D1 into D10)) must be written in cell D10.

     

    Let me know if I wasn't clear.

     

    If you haven't yet discovered the Numbers User Guide, it's available from the Help menu and is a worthwhile read.

     

    Thanks,

     

    Jerry

  • Jerrold Green1 Level 7 Level 7 (28,120 points)
    Currently Being Moderated
    Feb 1, 2013 12:26 PM (in response to nandi)

    nandi wrote:

     

    Thanks Jerry, so if I understand you, I say

     

    In Cell F5

    IF(B5>B6, "Text A","Text B")

     

    In Cell G9

    IF(B5>B6, B9,B10

    or possibly

    IF(B5>B6, =sum(B9),=sum(B10))

     

    both of these just sit as text in the cell and do not get recognized as programing.

    the first one was directly copied from the help center IF functions page.

    Very close...

     

    In Cell F5

    =IF(B5>B6, "Text A","Text B")

     

    In Cell G9

    =IF(B5>B6, B9,B10)

    or

    =IF(B5>B6, sum(B9),sum(B10))  [This would work, but SUM(B9) is the same as B9.]

     

    ...will work.

     

    Jerry

  • Jerrold Green1 Level 7 Level 7 (28,120 points)
    Currently Being Moderated
    Feb 1, 2013 2:26 PM (in response to nandi)

    I think you will enjoy programming in Numbers. I suggest that you read the first few chapters or so of the Numbers User Guide. Spend an evening with the guide with your favorite beverage at your side. It's a free download from the Numbers Help menu.

     

    Jerry

  • Jerrold Green1 Level 7 Level 7 (28,120 points)
    Currently Being Moderated
    Feb 1, 2013 4:57 PM (in response to nandi)

    Cells inspector, Conditional Format. Well covered in the Guide.

     

    Jerry

  • Jerrold Green1 Level 7 Level 7 (28,120 points)
    Currently Being Moderated
    Feb 2, 2013 1:22 PM (in response to nandi)

    Nandi,

     

    The "Condition" is a particular string of text. Here's an example where I set the default text color to Red and conditionally formatted it to Green...

     

    Screen Shot 2013-02-02 at 4.16.55 pm.png

    Text A is whatever you decide to make it. In your example, it's whatever you put in the formula.

     

    Jerry

  • Barry Level 7 Level 7 (29,095 points)
    Currently Being Moderated
    Feb 3, 2013 11:05 PM (in response to nandi)

    "For example if B1<B2 then B3 should read the number in B1 (this number changes daily) and turn a color."

     

    Conditional formatting rules compare the contents of the cell to be formatted (B3 in this case) with either a fixed value, or with the value in another cell.

     

    In the case you describe, what is to determine the colour used for the number in B3?

     

    Regards,

    Barry

  • Barry Level 7 Level 7 (29,095 points)
    Currently Being Moderated
    Feb 4, 2013 10:28 AM (in response to nandi)

    Hi nandi,

     

    The formula compares the values in cells B5 and B6. 

    There is no criterion for the number in B9 to meet, other than being in cell B9.

    There is no criterion for the number in B10 to meet, other than being in cell B10.

     

    IF the value in B5 is greater than the value in B6, THEN whatever value is in B9 is copied to B11.

    IF the value in B5 is NOT greater than the value in B6, THEN whatever value is in B10 is copied to B11.

    The table below shows the effect of that formula, revised to fit the column it is in, for the three possible cases in rows 5 and 6.

     

    The text colour is NOT set in the formula.

    Picture 8.png

     

    The text colour setting is format not content, and cannot be placed in the formula. It is controlled by a Conditional Format rule, set in the Cell Inspector. The first two rules in the box below the table are for cell B11.

    If the value in B11 is equal to that in B9, then the text colur is set to the green shown in the Text: Color Well in the first rule.

    If the first rule's condition is NOT met, then the second rule is checked.

    If the value in B11 is equal to that in B10, then the text colur is set to the red shown in the Text: Color Well in the second rule.

     

    As those are the only two values possible for B11, no further rules are necessary.

    The third (unset) rule is included only to show the icon at the right end of the box where the condition value is entered,

    To enter a fixed value, type it into the box.

    To reference a cell, click the icon, then click the cell whose vlue is to be compared to the value in B11.

     

    The conditional rules for cells C11 and D11 are the same as for B11, but compare the value in their cells with C9 C10 and D9 D10 respectively.

     

    Regards,

    Barry

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.