Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2018, 04:02 AM
ganesang ganesang is offline Need macro to merge columns Windows XP Need macro to merge columns Office 2016
Competent Performer
Need macro to merge columns
 
Join Date: Jul 2018
Posts: 171
ganesang is on a distinguished road
Default Need macro to merge columns

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
Attached Files
File Type: docx sample.docx (16.1 KB, 10 views)
Reply With Quote
  #2  
Old 11-28-2018, 03:34 PM
macropod's Avatar
macropod macropod is offline Need macro to merge columns Windows 7 64bit Need macro to merge columns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 11-28-2018, 10:46 PM
ganesang ganesang is offline Need macro to merge columns Windows XP Need macro to merge columns Office 2016
Competent Performer
Need macro to merge columns
 
Join Date: Jul 2018
Posts: 171
ganesang is on a distinguished road
Default

Thanks Much!!! Paul

Its work fantastic....
Reply With Quote
Reply



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
Need macro to merge columns 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:09 PM.


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