![]() |
|
#1
|
|||
|
|||
|
I need the help to merge two columns table data with one column without affecting each rows value. I have attached the Input and Output which is what i need exactly. Can anyone please check and help me out on this... Thanks Ganesan. G |
|
#2
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long, i As Long, StrCol1 As String, StrCol2 As String, StrTmp As String
With ActiveDocument.Tables(1)
For r = 1 To .Rows.Count
If Len(.Cell(r, 1).Range.Text) > 2 Then
StrTmp = ""
StrCol1 = Split(.Cell(r, 1).Range.Text, vbCr)(0)
StrCol2 = Split(.Cell(r, 2).Range.Text, vbCr)(0)
For i = 0 To UBound(Split(StrCol1, Chr(11)))
StrTmp = StrTmp & Split(StrCol1, Chr(11))(i) & " " & Split(StrCol2, Chr(11))(i) & Chr(11)
Next
StrTmp = Left(StrTmp, Len(StrTmp) - 1)
.Cell(r, 1).Range.Text = StrTmp
End If
Next
.Columns(2).Delete
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thanks Much!!! Paul
Its work fantastic....
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| merge blocks of columns into a single page | GEORGEJUNGCOCAINE | Excel Programming | 3 | 02-17-2018 08:36 AM |
How do I mail merge records into table columns with more than one merge field?
|
tech123 | Mail Merge | 1 | 04-26-2017 07:13 PM |
| Merge csv data onto one A4 page containing columns | gerrymac | Word | 1 | 04-17-2016 02:32 PM |
| Merge columns in files | dapeamel | Excel | 1 | 03-11-2015 05:26 AM |
| How to merge two columns & replace contents of cells conditionally? | mag | Excel | 3 | 10-24-2012 01:07 PM |