none
How to use VB to Change cell background color depending on input RRS feed

  • Question

  • Hello Everyone,

    What is the best way to code on how to change the background color of a cell depending on the input? I have a column named "Contacts", now depending  my answer (Being: Plant, Installers, EE, CompSys) i want the cell to change automatically when i enter the data.

    Plant - red background in cell; Installers - light blue; EE - orange; CompSys: yellow background 

    Any Suggestions? Thank you for your time

    Thursday, October 30, 2014 6:43 PM

All replies

  • Hi Erick,

    Its not possible to do conditional formatting based on a 'Contacts' Column.  you can colour code a single item using by setting the 'Marked' column to 'Yes' for a selection of Tasks then use the 'Text Styles' tool to highlight the 'Marked' cells in a particular colour.  I understand that this won't do what you want but that this limitation of the system.

    I would suggest that you create a view that Groups the resources by the 'Contacts' then you could manually colour code the cells quite quickly

    Hope this helps



    • Edited by Tom_Henry Thursday, October 30, 2014 7:37 PM typo
    Thursday, October 30, 2014 7:00 PM
  • In addition to Tom's excellent answer, it should be possible to do so with some VBA. Surely John or Rod will jump in to provide some help.

    As Tom said, if you're willing to avoid VB code, you could use some workaround such as having custom indicator fields (flags) with a formula set to YES depending on the contact then doing a specific bar format in the Gantt chart based on those indicators.


    Hope this helps,


    Guillaume Rouyre, MBA, MVP, P-Seller |

    Thursday, October 30, 2014 7:05 PM
    Moderator
  • Rather have it set in Vb code.
    Thursday, October 30, 2014 7:58 PM
  • EricReynolds,

    Indeed this is only possible with VBA. There are two ways to accomplish what you want with VBA. The simplest is to set up a macro initiated by the user once the changes have been entered. That of course requires two steps - entering the info in your custom field and running the macro to color the background. A second approach is to use an Event based macro that fires when a change is made, however Event based macros, other than an Open or Close Event, are more complicated to set up.

    So the question is, how game are you for doing what you want? If you want to see the scope of what is necessary to do a Change Event macro, see Jack Dahlgren's webpage at: http://masamiki.com/project/project_open.htm

    John


    • Edited by John - Project Thursday, October 30, 2014 9:33 PM reference
    Thursday, October 30, 2014 8:20 PM