change colour of cell in word table following numerical input

  • Thread starter Taffline Davies
  • Start date
T

Taffline Davies

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
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
580
Reaction score
50
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
 

Attachments

  • FormConditionalFormatting.zip
    11.3 KB · Views: 338

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. After that, you can post your question and our members will help you out.

Ask a Question

Top