![]() |
#1
|
|||
|
|||
![]()
How can I add a text string at the beginning of each of the lefthand cells in a table?
Lets say the cell contains "1:2" I wish to add "Gen. " so that it reads "Gen. 1:2" The start of every lefthand cell must be set to "Gen. " |
#2
|
|||
|
|||
![]() Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oTbl As Table Dim oCell As Cell Set oTbl = Selection.Tables(1) For Each oCell In oTbl.Range.Cells If oCell.ColumnIndex = 1 Then If Len(oCell.Range.Text) > 2 Then oCell.Range.InsertBefore "Gen " End If End If Next lbl_Exit: Exit Sub End Sub Sub ScratchMacro2() 'A basic Word macro coded by Greg Maxey Dim oTbl As Table Dim oCol As Column Dim oCell As Cell Set oTbl = Selection.Tables(1) If oTbl.Uniform Then Set oCol = oTbl.Columns(1) For Each oCell In oCol.Cells If oCell.ColumnIndex = 1 Then If Len(oCell.Range.Text) > 2 Then oCell.Range.InsertBefore "Gen " End If End If Next End If lbl_Exit: Exit Sub End Sub If the table is uniform, the second macro will be faster. |
#3
|
|||
|
|||
![]()
Thank you!
|
![]() |
Tags |
cell, table, word 365 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ndajko | Word | 5 | 11-04-2019 07:53 AM |
![]() |
ashalles135 | Word VBA | 5 | 09-26-2018 09:49 AM |
![]() |
ArieH | Word VBA | 20 | 09-10-2017 04:23 PM |
![]() |
ellentk | Word Tables | 3 | 09-09-2015 03:33 PM |
![]() |
ballmoney | Word | 1 | 01-17-2010 02:19 AM |