Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-26-2019, 02:05 AM
gmayor's Avatar
gmayor gmayor is offline Macro to format all occurrences of a text in a table Windows 10 Macro to format all occurrences of a text in a table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

Probably something like
Code:
Sub Macro1()
Dim oTable As Table
Dim oRng As Range
Dim oRow As Row
Const strText As String = "Text to find"
    Set oTable = Selection.Tables(1)
    For Each oRow In oTable.Rows
        If InStr(1, oRow.Range, strText) > 0 Then
            Set oRng = oRow.Range
            oRow.ConvertToText Separator:=Chr(9)
            oRng.Font.Bold = True
            oRng.Font.Size = 14
            oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
            oRng.InsertParagraphBefore
        End If
    Next oRow
lbl_Exit:
    Set oTable = Nothing
    Set oRng = Nothing
    Set oRow = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to format all occurrences of a text in a table How to I create a macro that dynamically creates a table, to enter questions, in the below format? MathiasFC Word VBA 11 01-14-2019 04:50 PM
Macro to format all occurrences of a text in a table Macro to delete text from cells with specific format Soenke Word VBA 4 09-01-2016 08:55 AM
Macro to format all occurrences of a text in a table Variable text field code based on occurrences on each page Cosmo Word 2 12-29-2015 11:54 AM
Macro to find text in between two characters and then format selected text? qcom Word 5 02-19-2015 11:23 PM
Macro to format all occurrences of a text in a table Replace all occurrences of one merge field with plain text blankenthorst Mail Merge 5 07-01-2011 05:18 AM

Other Forums: Access Forums

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