I want to insert

Dr^s (non breaking space)

as 1st word in Column 1 of a table (the rows already exist). I just want it
to run down the 1st column and insert the above word with a nonbreaking
space before the text already inserted? Is anyone able to help with VBA
please?

Much appreciated.

Re: Table 1st col Insert Word by Helmut

Helmut
Sat May 10 01:45:12 PDT 2008

Hi Jen,

like that:

Sub TestDr()
Dim oTbl As Table
Dim oRow As Row
Dim sTmp As String
Set oTbl = Selection.Tables(1)
For Each oRow In oTbl.Rows
With oRow.Range.Cells(1).Range
If Left(.Text, 3) <> "Dr" & Chr(160) Then
sTmp = Left(.Text, Len(.Text) - 2)
sTmp = "Dr" & Chr(160) & sTmp
.Text = sTmp
End If
End With
Next
End Sub

Post back, if you have vertically merged cells,
as in that case things get a bit more complicated.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: Table 1st col Insert Word by Jen

Jen
Sat May 10 02:58:16 PDT 2008

Many thanks Helmut - works like a charm as always.

"Helmut Weber" <red.sys@t-online.de> wrote in message
news:4gna24ll05a6osudf5oaecr5urtgksgm3c@4ax.com...
> Hi Jen,
>
> like that:
>
> Sub TestDr()
> Dim oTbl As Table
> Dim oRow As Row
> Dim sTmp As String
> Set oTbl = Selection.Tables(1)
> For Each oRow In oTbl.Rows
> With oRow.Range.Cells(1).Range
> If Left(.Text, 3) <> "Dr" & Chr(160) Then
> sTmp = Left(.Text, Len(.Text) - 2)
> sTmp = "Dr" & Chr(160) & sTmp
> .Text = sTmp
> End If
> End With
> Next
> End Sub
>
> Post back, if you have vertically merged cells,
> as in that case things get a bit more complicated.
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP