Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2021, 06:52 PM
roadwarrior99 roadwarrior99 is offline Trouble using coding for Macro to join tables from directory merger Windows 10 Trouble using coding for Macro to join tables from directory merger Office 2016
Novice
Trouble using coding for Macro to join tables from directory merger
 
Join Date: Jul 2021
Posts: 1
roadwarrior99 is on a distinguished road
Default Trouble using coding for Macro to join tables from directory merger

Hi! I really need help figuring out what codes to use when joining tables from a direct merger. So far I've copied a couple of codes from someone online but it's not quite what I need in the macro. In fact, when I changed the macro the tables remained the same. Ugh. I'm so frustrated

This is what I used:

Sub UpdateAll()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing


Exit Sub
End Sub

However, I only need one header and no extra rows in between the tables. That's all I need to complete this project. I'm definitely not an expert

Please Help anybody!
Attached Images
File Type: jpg direct merger issue.jpg (104.3 KB, 7 views)
Reply With Quote
  #2  
Old 07-24-2021, 08:19 PM
gmayor's Avatar
gmayor gmayor is offline Trouble using coding for Macro to join tables from directory merger Windows 10 Trouble using coding for Macro to join tables from directory merger Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

To fix your table you need to delete the unwanted rows e.g. as below however this looks like a many to one mail merge.See Merge Many To One
Code:
Sub Macro1()
Dim i As Long
Dim oTable As Table
Dim oRng As Range
    Set oTable = ActiveDocument.Tables(1)
    For i = oTable.Rows.Count To 3 Step -1
        Set oRng = oTable.Rows(i).Cells(1).Range
        oRng.End = oRng.End - 1
        If oRng.Text = "Assessment/Category" Or oRng.Text = "" Then
            oTable.Rows(i).Delete
        End If
    Next i
    Set oTable = Nothing
    Set oRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 07-24-2021 at 11:28 PM.
Reply With Quote
Reply

Tags
direct merger, table joiner

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble using coding for Macro to join tables from directory merger Would like to shortern the coding for searching docx file names in specific directory SamDsouza Word VBA 4 01-06-2021 07:27 AM
Trouble using coding for Macro to join tables from directory merger Want Macro to join lines and delete numbers Benali Word VBA 11 04-30-2020 07:57 AM
Word VBA coding for tables Dont know Word VBA 5 02-18-2020 05:31 PM
Directory Mail Merge Trouble Murph14 Mail Merge 5 06-03-2015 12:22 AM
Trouble using coding for Macro to join tables from directory merger Coding into a macro a carriage return sinbad Word VBA 6 02-27-2012 03:51 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:06 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