How to create macro in Word table

E

Eric

Hi There,

I need help from you guys who are expert in creating macro programming in Word, Here's the situation, I have a table say seven rows and seven column, my first rows is composed of numbers (in text) I want to search starting from the second row down to the last row, If I find the match numbers below I want to change to color of that number to RED, then go again find another numbers that match to my search number... and so on

Can any one help me on this problem please.

Thanks in advance
Eric
 
D

Doug Robbins - Word MVP

Hi Eric,

Use:

Dim atable As Table, mydata As Range, arange As Range, i As Integer, j As
Integer, k As Integer
Set atable = ActiveDocument.Tables(1)
For i = 1 To atable.Columns.Count
Set mydata = atable.Cell(1, i).Range
For j = 2 To atable.Rows.Count
For k = 1 To atable.Columns.Count
Set arange = atable.Cell(j, k).Range
If arange.Text = mydata.Text Then
arange.Font.Color = wdColorRed
End If
Next k
Next j
Next i

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Eric said:
Hi There,

I need help from you guys who are expert in creating macro programming in
Word, Here's the situation, I have a table say seven rows and seven column,
my first rows is composed of numbers (in text) I want to search starting
from the second row down to the last row, If I find the match numbers below
I want to change to color of that number to RED, then go again find another
numbers that match to my search number... and so on
 

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