Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-20-2016, 01:53 AM
macropod's Avatar
macropod macropod is offline Overcome issues in tables with vertically merged cells Windows 7 64bit Overcome issues in tables with vertically merged cells Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,513
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


If the heading uses a Heading Style (or some other Style whose scope is limited to headings), simply use Find/Replace to look for the Style as part of the Find parameters, then test whether it's in a table and, if so, get the cell's RowIndex - if it's 1 it's on the first row, and if it's 2 it's on the second row, thus:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = InputBox("What is the Text to Find")
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .Style = "Heading 1"
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    If .Information(wdWithInTable) Then
      If .Cells(1).RowIndex < 3 Then
        'Do something with the heading
        MsgBox .Text
      End If
    ElseIf .End = ActiveDocument.Range.End Then
      Exit Sub
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Even without employing Styles, you can still use the same general approach.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
tables;formula;automating



Similar Threads
Thread Thread Starter Forum Replies Last Post
Overcome issues in tables with vertically merged cells How to vertically align a merged cell to fit text paik1002 Excel 6 09-20-2016 03:00 AM
Combining 2 tables into 1 and use Table2's column widths (hoping for workaround dealing merged cells CodingGuruInTraining Word VBA 24 10-07-2015 07:48 PM
Overcome issues in tables with vertically merged cells Table will not allow sorting because "cells are merged". I can't find the merged cells. wendyloooo Word Tables 1 05-26-2015 01:19 PM
Overcome issues in tables with vertically merged cells Unable to vertically center align texts in table cells? tinfanide Word 3 11-24-2013 06:37 AM
How to merge matching cells vertically? Odiseh Excel 1 01-02-2010 02:41 PM

Other Forums: Access Forums

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