![]() |
#2
|
||||
|
||||
![]()
Try something based on:
Code:
Sub Demo() Application.ScreenUpdating = False Dim oTbl As Table, i As Long, r As Long, Rng As Range For Each oTbl In ActiveDocument.Tables With oTbl If InStr(.Cell(1, 2).Range.Text, "#CPT") > 0 Then Set Rng = .Cell(2, 1).Range With Rng .End = .End - 1 .InsertBefore "(Year) " i = InStr(.Text, " ") With .Duplicate .End = .Start + i .Font.ColorIndex = wdBlue End With .InsertAfter " (Building)" i = InStrRev(.Text, " ") With .Duplicate .Start = .Start + i .Font.ColorIndex = wdBlue End With End With Set Rng = .Cell(2, 2).Range With Rng .End = .End - 1 .InsertBefore "(QID) " i = InStr(.Text, " ") With .Duplicate .End = .Start + i .Font.ColorIndex = wdBlue End With .InsertAfter " (Total)" i = InStrRev(.Text, " ") With .Duplicate .Start = .Start + i .Font.ColorIndex = wdBlue End With End With For r = 3 To .Rows.Count Set Rng = .Cell(r, 1).Range With Rng .End = .End - 1 .InsertBefore "(student) " i = InStr(.Text, " ") With .Duplicate .End = .Start + i .Font.ColorIndex = wdBlue End With .InsertAfter " (Course)" i = InStrRev(.Text, " ") With .Duplicate .Start = .Start + i .Font.ColorIndex = wdBlue End With End With Set Rng = .Cell(r, 2).Range With Rng .End = .End - 1 .InsertBefore "(previous) " i = InStr(.Text, " ") With .Duplicate .End = .Start + i .Font.ColorIndex = wdBlue End With .InsertAfter " (Pass)" i = InStrRev(.Text, " ") With .Duplicate .Start = .Start + i .Font.ColorIndex = wdBlue End With End With Next End If End With Next Set Rng = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jc491 | Word VBA | 8 | 09-30-2015 06:10 AM |
Word 2013 - linking cell data within a table | jhamblin | Word Tables | 1 | 03-15-2015 01:32 AM |
![]() |
aarun2 | Word VBA | 1 | 04-08-2014 03:20 PM |
Append text to a sentence containing specific word | dgp | Word VBA | 3 | 02-28-2014 10:38 PM |
Word table - how do I append % symbol to each value in columns 3 & 4 of a table | Dawsie | Word | 4 | 03-06-2013 12:33 AM |