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?

    Thanks
     
    Taffline Davies, Feb 7, 2012
    #1
    1. Advertisements

  2. Taffline Davies

    macropod

    Joined:
    Mar 2, 2012
    Messages:
    134
    Likes Received:
    9
    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
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Kim
    Replies:
    1
    Views:
    101
    Word Heretic
    Aug 4, 2003
  2. MikeM

    varify the input in a table

    MikeM, Oct 2, 2003, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    99
    Mark Tangard
    Oct 3, 2003
  3. Peter
    Replies:
    1
    Views:
    95
    Dave Lett
    Jul 19, 2004
  4. Robert

    Insert a Section in Numerical Order

    Robert, Sep 24, 2004, in forum: Word VBA Beginners
    Replies:
    2
    Views:
    86
    Guest
    Sep 27, 2004
  5. Pu
    Replies:
    2
    Views:
    80
    Jay Freedman
    Mar 7, 2005
  6. Simon

    copying current page plus following 2 pages

    Simon, Sep 28, 2005, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    86
  7. Blackberry
    Replies:
    11
    Views:
    207
    Blackberry
    Oct 10, 2007
  8. StargateFanWrk

    Macro to apply alternate row colour to a table (15% grey)?

    StargateFanWrk, Dec 3, 2009, in forum: Word VBA Beginners
    Replies:
    4
    Views:
    250
    StargateFanWrk
    Dec 4, 2009
Loading...