+ Reply to Thread
Results 1 to 7 of 7

Conditional formatting Macro

  1. #1
    Registered User
    Join Date
    06-25-2007
    Location
    Dingwall, Scotland
    Posts
    10

    Conditional formatting Macro

    Hi guys

    I have a spreadsheet with the following code:

    Please Login or Register  to view this content.
    How can I add if the cell value is any other text that that specified it goes another colour?

    And how do I add code to change the colour of the cell borders?

    Any advice would be appreciated!
    Last edited by VBA Noob; 07-10-2007 at 01:10 AM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    PLease read forum rules. Could must be wrapped

    Doesn't your Case Else change the unlisted situations colours?
    The macro recorder will show you the syntax for changing border colours.
    Last edited by VBA Noob; 07-10-2007 at 01:11 AM.

  3. #3
    Registered User
    Join Date
    06-25-2007
    Location
    Dingwall, Scotland
    Posts
    10

    Cool

    Sorry for not wrapping the code - I'm new to this game!

    The background of my workbook is grey, the cell range in question is populated after performing a If/Vlookup query. If after the query a value is returned and the value is NOT one of those in the code e.g. "Bakerloo Line", "Central Line" etc I want the cells to turn white.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    If you want white
    Please Login or Register  to view this content.
    If you want "no fill"
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-25-2007
    Location
    Dingwall, Scotland
    Posts
    10

    Cool

    I need an additional argument which turns the cells white when text [this can be any text whatsover] OTHER than that in the code populates the cells. My Case Else line leaves the cells grey when no text appears.

    Does that make sense?

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The Case <> vbNullString does what you want. It must be after all of the other options have been checked, but before Case Else.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-25-2007
    Location
    Dingwall, Scotland
    Posts
    10
    That's great that's just what I need.

    All I have to do now is figure out how to change the border colours.

    Thanks for your help!

+ 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