View Single Post
 
Old 04-14-2021, 10:35 AM
Steve Kunkel Steve Kunkel is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: May 2019
Location: Seattle area
Posts: 81
Steve Kunkel is on a distinguished road
Default Want to Insert Column and add text into entire column.

Hi Folks,
Given an existing table in Word, I'd like to insert a new column to the left of where the cursor is, then enter some text. I want the same text repeated down the entire column.

You can see what I have. If I get my desired text copied to the clipboard, then Selection.Paste does the job, but I'd prefer if the text came from the text box "txtColumn" that is on my user form.

Note that these two:
Code:
    Selection.TypeText (txtColumn.Value)
    Selection.InsertBefore Text:="teacher"
only insert the text into one cell (even if the entire column is selected).

Does this require a loop or something??
Ideas?


Code:
Private Sub cmdMakeColLeft_Click()
    Selection.InsertColumns
    Selection.MoveLeft Unit:=wdCell
    Selection.SelectColumn
    'Selection.TypeText (txtColumn.Value)
    'Selection.InsertBefore Text:="teacher"
    Selection.Paste
End Sub

Last edited by Steve Kunkel; 04-14-2021 at 07:23 PM. Reason: Added code tags; added solved
Reply With Quote