Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-29-2022, 07:58 AM
ericliu24 ericliu24 is offline How to combine the texts of all cells in a column without line break. Windows 10 How to combine the texts of all cells in a column without line break. Office 2019
Novice
How to combine the texts of all cells in a column without line break.
 
Join Date: Mar 2022
Location: China
Posts: 21
ericliu24 is on a distinguished road
Default How to combine the texts of all cells in a column without line break.

I try to combine the texts of all cells in a column into a paragraph.



For example:

Table is like :

1 this
2 is
3 great

I would like to get "this is great".

But my code below always return
" this
is
great"

Could you please help me out. Many thanks.

Code:
Sub TEST1()
Dim c As Long
Dim String1 As String

With ActiveDocument.Tables(1)
For r = 1 To .Rows.Count
String1 = String1 & .Cell(r, .Columns.Count).Range.Text
'Debug.Print String1
Next r

End With

With ActiveDocument.SelectContentControlsByTitle("text1")(1)

     '.LockContentControl = False
     .Range.Text = String1
     '.LockContentControl = True
    End With
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to combine the texts of all cells in a column without line break. Table styles - First column shading with bottom line on page break NicB Word Tables 2 02-20-2019 03:05 AM
How to combine the texts of all cells in a column without line break. Organise cells with line break into separate rows vjvj123 Excel Programming 6 09-26-2018 09:19 AM
How to combine the texts of all cells in a column without line break. Word converts section break to page break before columns, does not insert column breaks eborda Word 1 03-24-2017 11:06 PM
Interchange line break and paragraph break shortcut keys skan Word 2 01-20-2017 03:50 AM
How to automatically insert a line after a Column Break YooperNC Word 3 01-29-2015 07:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft