Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
motocrossed
 
Posts: n/a
Default color coding cells

I use a word table to track project updates, The fields are "entry
number", "project", "date", and "notes". The table get reviewed by
quite a few people and I have a legend at the bottom of the table that
shows the color for each project. I would like to be able to enter the
project in a cell and have it automatically enter the color code for
that project. I know I can do this with Excel but I found it easier to
use Word for this process as the table is heavily text oriented.

thanks

  #2   Report Post  
Posted to microsoft.public.word.tables
Cooz
 
Posts: n/a
Default color coding cells

Hi motocrossed,

You can't have Word do that automaticaly for you the way Excel does, but you
can run a macro afterwards that applies cell colors depending on the contents
of the cell.

Sub ColorCells()
Dim aTable As Table, aCell As Cell

If Selection.Information(wdWithInTable) Then
Set aTable = Selection.Tables(1)
For Each aCell In aTable.Range.Cells
With aCell
Select Case UCase(Left(.Range.Text, Len(.Range.Text) - 2))
Case "A"
.Shading.BackgroundPatternColor = wdColorAqua
Case "B"
.Shading.BackgroundPatternColor = RGB(89, 43, 121)
Case "C"
.Shading.BackgroundPatternColor = RGB(200, 143, 21)
Case "D"
.Shading.BackgroundPatternColor = wdColorGold
Case Else ' white
.Shading.BackgroundPatternColor = wdColorWhite
End Select
End With
Next aCell
Else
MsgBox "Place the cursor in the table, and run the macro again.", _
vbCritical + vbOKOnly, "Color Cells"
End If

End Sub

A few remarks:
- Check http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm on how to
install the macro in Word. The article says "select the template you want to
store the macro in" but you can store the macro in your document as well.
- Substitute "A", "B", "C" and "D" for your own text in capitals. If you
want the macro to be case sensitive, remove "UCase(" and the last ")" from
the line
Select Case UCase(Left(.Range.Text, Len(.Range.Text) - 2)) and provide your
texts the way you want them instead of "A", "B", "C" and "D".
- Substitute wdColorX and RGB(R, G, B) for your own colors. If you for
example delete "= wdColorAqua" from ".Shading.BackgroundPatternColor =
wdColorAqua" and type =, Word displays a list of color constants you can use.
You can also make up your own colors by mixing red, green and blue values
(0-255) in RGB(R, G, B) - e.g. RGB(255, 255, 255) results in white.
- You can of course add more lines like
Case X
.Shading.BackgroundPatternColor = Y
to the list.

Good luck,
Cooz


"motocrossed" wrote:

I use a word table to track project updates, The fields are "entry
number", "project", "date", and "notes". The table get reviewed by
quite a few people and I have a legend at the bottom of the table that
shows the color for each project. I would like to be able to enter the
project in a cell and have it automatically enter the color code for
that project. I know I can do this with Excel but I found it easier to
use Word for this process as the table is heavily text oriented.

thanks


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell border confusion after cells are merged Hack Tables 5 February 22nd 06 01:30 PM
I want text from the cells in one table repeated in other tables Reg Tables 2 February 14th 06 01:53 PM
cell's background color not printed correctly [email protected] Tables 2 December 19th 05 12:44 PM
Insert Column when merged cells exist Brian Kaplan Tables 2 December 5th 05 05:13 PM
Linking Excel cells to a Word document jada Mailmerge 3 November 14th 05 08:17 PM


All times are GMT +1. The time now is 10:10 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"