![]() |
#4
|
||||
|
||||
![]()
It seems to me you're trying to deal with the problem from the wrong end. It would be far simpler to correct the data before merging. Try the following macro on your source document:
Code:
Sub SourceTableReformat() Application.ScreenUpdating = False Dim r As Long, x As Long, y As Long, Rng As Range, StrTxt As String With ActiveDocument.Tables(1) For r = .Rows.Count To 2 Step -1 With .Rows(r) StrTxt = Split(.Cells(4).Range.Text, vbCr)(0) x = UBound(Split(StrTxt, ",")) If x > 0 Then Set Rng = .Range For y = 1 To x - 1 Rng.Collapse wdCollapseEnd Rng.FormattedText = .Range.FormattedText Rng.Cells(4).Range.Text = Trim(Split(StrTxt, ",")(y)) Next .Cells(4).Range.Text = Trim(Split(StrTxt, ",")(0)) End If End With Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Alex1s85 | Word VBA | 5 | 05-22-2021 12:05 PM |
Split data in cells and duplicate rows | ballpoint | Excel Programming | 6 | 02-07-2018 05:52 PM |
![]() |
gideonpm | Mail Merge | 3 | 12-22-2016 01:20 PM |
Macro Winword mailmerge split printpage with mergefield as filename | pca | Word VBA | 2 | 02-28-2014 02:43 PM |
Can I do this? sorting data in seperate columns | shumonsaha | Excel | 0 | 07-04-2010 03:05 AM |