+ Reply to Thread
Results 1 to 6 of 6

Changing cell formatting with an IF statement

  1. #1
    Registered User
    Join Date
    09-22-2006
    Location
    Western Arkansas
    MS-Off Ver
    2016
    Posts
    75

    Changing cell formatting with an IF statement

    I have an area of a spreadsheet that I want to "disappear" when a particular option button is selected. I can make the text go away, but part of that area has cells that are formatted differently than the surrounding cells. I would like to change the cell background color, text color, and border setting. How would the syntax read?

    Thanks.
    Last edited by VBA Noob; 11-18-2008 at 03:03 PM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Use:
    format
    conditional formatting

    choose the "formula is" option and put the formula as something along the lines of:
    =$cellcolumn$cellrow=<criteria for changing format>
    Where the cell in question is the one whose change defines whether or not the cells should be visible

    Change the format as appropriate

    The alternative is to use value is and value is ="" (which I presume is the result which makes the values "disappear") this needs a relative reference (no $s) to the activecell in the selection when you apply the format.

    HTH

  3. #3
    Registered User
    Join Date
    09-22-2006
    Location
    Western Arkansas
    MS-Off Ver
    2016
    Posts
    75
    I'm not sure I completely understand your reply, but I should point out that the cells that I would like to change cannot hold the formula that changes them. They have to have a number in them. I need to be able to write a formula that will assess the value of one cell and change the format of another cell based on that value.

  4. #4
    Valued Forum Contributor Rahul Nagar's Avatar
    Join Date
    09-18-2008
    Location
    nasik
    MS-Off Ver
    Excel 2003
    Posts
    465
    Hello jmoffett,

    Can you please attached file for more details so i can help you

    regards
    rahul

  5. #5
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Open a new workbook
    Select some cells - let's try C3:F16 - after you drag the area out you should see cell C3 is white within the selection (it is the active cell) it should also say C3 in the name box (above the 'A' of column A).
    Goto:
    Format
    Conditional Formatting
    Change the first box to "formula is"
    Type this in:
    =$A3="pie"
    Click the format button
    Select the patterns tab
    Change the cell interior colour to a lovely pink hue
    OK
    OK

    Now type 'pie' (no quotes) into A3, A6, A9

    See how the format of the cells depends on the contents of another cell?

    If you changed the reference to absolute for row and column, i.e. =$A$3="pie" The whole area would change format depending on the contents of A3.

    If you made it entirely relative, i.e. =A3="pie" then the format would apply the pink shade to any cell whose neighbour two to the left holds "pie".

    I hope by now this all makes sense.

    HTH

    mmm... pie

  6. #6
    Registered User
    Join Date
    09-22-2006
    Location
    Western Arkansas
    MS-Off Ver
    2016
    Posts
    75
    Beautiful! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1