Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2022, 04:51 AM
TheBigBoss TheBigBoss is offline Parsing and modifying text per line - Find occurences Windows 7 32bit Parsing and modifying text per line - Find occurences Office 2010 32bit
Advanced Beginner
Parsing and modifying text per line - Find occurences
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default Parsing and modifying text per line - Find occurences

Hi there,

Sorry for the title being almost meaningless.

I have a table, one cell contains a single line or multiple lines of reference (e.g TST/PRF/25/64)

I need to do the following for EACH line:
a) Content before the first slash must be bold, 14pt
b) Content after the first slash is not bold, 11pt
...BUT if content at the second slash is "VST" or "PKE" then it should be bold, 14pt too.



I really failed on that one, ranges and moving in ranges get me crazy
Some help would be grateful

Attached is the TEST-reference.dotm with the FixIt macro.
Attached Files
File Type: dotm TEST-reference.dotm (28.7 KB, 20 views)
Reply With Quote
  #2  
Old 11-09-2022, 06:31 AM
gmayor's Avatar
gmayor gmayor is offline Parsing and modifying text per line - Find occurences Windows 10 Parsing and modifying text per line - Find occurences Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

There is no code in your template, however
Code:
Sub Macro1()
Dim oTable As Table
Dim oCell As Cell
Dim oRow As Row
Dim oPara As Paragraph
Dim oRng As Range
    Set oTable = Selection.Tables(1)
    For Each oRow In oTable.Rows
        Set oCell = oRow.Cells(2)
        oCell.Range.Font.Size = 11
        For Each oPara In oCell.Range.Paragraphs
            Set oRng = oPara.Range
            oRng.Collapse (1)
            oRng.MoveEndUntil "/"
            oRng.Font.Bold = True
            oRng.Font.Size = 14
            oRng.Collapse (0)
            oRng.Start = oRng.Start + 1
            oRng.MoveEndUntil "/"
            If InStr(1, oRng.Text, "VST") > 0 Or _
               InStr(1, oRng.Text, "PKG") > 0 Then
                oRng.Start = oRng.Start - 1
                oRng.Font.Bold = True
                oRng.Font.Size = 14
            End If
        Next oPara
    Next oRow
    Set oTable = Nothing
    Set oCell = Nothing
    Set oRow = Nothing
    Set oPara = 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
Reply With Quote
  #3  
Old 11-09-2022, 11:00 PM
TheBigBoss TheBigBoss is offline Parsing and modifying text per line - Find occurences Windows 7 32bit Parsing and modifying text per line - Find occurences Office 2010 32bit
Advanced Beginner
Parsing and modifying text per line - Find occurences
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default

Hi Graham,

Thanks for your reply.
My bad, after verification in the Visual Consol, I actually wrote the macro in my Normal.dotm. Sorry.

Thanks for the code, it looks good to me. I will give it a try.
I was splitting at a slash but MoveEndUntil is a better alternative indeed as it moves along the process.
Reply With Quote
  #4  
Old 11-10-2022, 05:43 AM
TheBigBoss TheBigBoss is offline Parsing and modifying text per line - Find occurences Windows 7 32bit Parsing and modifying text per line - Find occurences Office 2010 32bit
Advanced Beginner
Parsing and modifying text per line - Find occurences
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default

I works like a charm. Thanks a lot for your help
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing and modifying text per line - Find occurences Count occurences of 2 words (that are near each other) petitfleur Word VBA 6 02-12-2020 10:40 PM
Find a text and delete the line above Dzib Word VBA 1 09-10-2019 12:27 PM
Parsing and modifying text per line - Find occurences Parsing 'FullName' column - help needed text to column ScottA Excel Programming 3 05-06-2014 12:49 PM
Parsing and modifying text per line - Find occurences Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Parsing and modifying text per line - Find occurences Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM

Other Forums: Access Forums

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