Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Changing cell colour (MSO2003 winxp pro)

    I am wishing to change the fill colour of a cell based on the result of the calculation in that cell.

    I thought this would be a fairly straight forward little thing to solve. Have tried { =b2*c2} which works fine and then tried { if(b2*c2>4,0,0) } and for the life of me I cannot figure out how to get the result and or cell to change colour.

    Can anyone help.
    cheers

    Phil Carter

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    4,986
    Thanks
    2
    Thanked 402 Times in 331 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Hi Phil,

    Word tables don't support the sort of conditional formatting that you can use in Excel to change a cell's colour. However, you can get a Word formula to format its results in different colours etc depending on the result. For more information on how to do this, see 'Formatting Numeric Field Results' in <post#=365442>post 365442</post#>

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Macropod thanks for that.

    I concur with others. That's a hell of a document.

    However, I just can't seem to get this formula right, { =If(b2*c2>4 # 0,0,0) } with the numeric picture formatted to show the result in "red". I keep getting this error message "!Unexpected End of Formula"
    cheers

    Phil Carter

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    It's not quite clear to me what tou want to accomplish, but you could try

    { IF { = B2 * C2 } > 4 "<font color=448800>Greater</font color=448800>" "<font color=red>Lesser</font color=red>" }

    where both the inner and outer brackets are field brackets (insert by pressing Ctrl+F9 or Insert | Field..., NOT by typing them)

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    I think maybe there is something missing. IF fields usually have a test, then a true result, then a false result -- with no commas.

    { IF 2 > 1 "Known laws of mathematics apply in this place." "Hang on to your hats!" }

    For the color, maybe you can do this: Have two IF fields, one that display only when true and one that displays only when false, one formatted black and the other formatted red. (Note: this would work for the text color, not the cell's background color.)

  6. #6
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Hans thanks for that

    This is driving me bananas!

    This is my code: { if { b2 * c2 } > 4 <font color=red>"High Risk!" </font color=red> <font color=448800>"Low Risk"</font color=448800> } doesn't work
    cheers

    Phil Carter

  7. #7
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Jefferson thanks as well

    I tried nesting IFs but couldn't that to work either!
    cheers

    Phil Carter

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    I wasn't suggesting nesting, but having them side-by-side. See the attached.
    Attached Files Attached Files

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Your embedded field doesn't look right. See the attached. It helps to test each embedded field separately as you go so you can rule out that kind of problem.

    Note: This document is not supposed to contain a macro. If asked, Disable macros in the attached document.
    Attached Files Attached Files

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    You didn't include the = in the inner field. Jefferson has posted some working examples (thanks, Jefferson!).

  11. #11
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Jefferson and Hans thanks again.

    I don't know where many of us would be without guys like you to lean on.

    I gather for conditional statements the numeric picture switches, that apply for straight calculations, do not work to enable the result to be coloured.
    cheers

    Phil Carter

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Color is not a numeric format, as far as I know. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> However, if you have positive and negative formats (separated by a semicolon), you can color them separately.

    Using the two-IF approach, you can select the entire field and apply any formatting you like "from the outside." When working with a single field, you'll have to carefully do it inside the field.

  13. #13
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Jefferson thanks again

    I'll probably leave well alone for now.
    cheers

    Phil Carter

  14. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    4,986
    Thanks
    2
    Thanked 402 Times in 331 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Hi Phil,

    See the attached file, in which I've given you three ways to solve this problem. The solution in A1 also allows for a 'Medium Risk' output if you want it. If not, you can simply delete the last semi-colon in the field and everything after it.

    Cheers
    Attached Files Attached Files
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  15. #15
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Changing cell colour (MSO2003 winxp pro)

    Macropod

    Thanks again. I am not sure I understand how the first option works {=b2*c2-4 # High Risk!;Low Risk;Medium Risk}.

    cheers
    cheers

    Phil Carter

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •