change colour of cell in word table following numerical input

Discussion in 'Word VBA Beginners' started by Taffline Davies, Feb 7, 2012.

  1. Hi,

    I have a table in a questionnaire that I want to change the colour of
    the cell dependent upon the number input to the cell. i.e. entering a
    1 will turn the cell red, 2 will turn the cell yellow and 3 will turn
    the cell green.

    Is there any way I can use a macro to do this?

    Taffline Davies, Feb 7, 2012
    1. Advertisements

  2. Taffline Davies

    macropod Microsoft MVP

    Mar 2, 2012
    Likes Received:
    Hi Taffline,

    See attached. The formfield uses an 'on exit' macro attached to the formfield to change its cell colour according to the number chosen. The macro that does the real work (CondFormat) is different to the one called by the 'on exit' macro (Dropdown1Colour), so it's easy to add the same functionality to other formfields and their cells. If, for example you wanted to have the same functionality for a dropdown formfield named 'Dropdown1', you could use an 'on exit' macro named Dropdown2Colour and coded as:
    Sub Dropdown2Colour()
    Call CondFormat("Dropdown2")
    End Sub

    Attached Files:

    macropod, Mar 2, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.