#1
|
|||
|
|||
Finding Symbols And Deleting Text Before And After It
Hello Community,
I am trying to put together a macro that would take the following text below Q330r1: Control of positive symptoms - Considering the information you just reviewed^ Q330R1 (1) Q330r2: Tolerability/ side effects - Considering the information you just reviewed^ Q330R2(1) Q330r3: Durability (ability to control symptoms from one injection to the next) - Considering the information you just reviewed^Q330R3 (1) Q330r4: Dosing schedule (frequency of dosing – 4 or 6 weeks) - Considering the information you just reviewed^Q330R4 (1) It would look for the ":" and delete anything to the left of it on that line. Then look for the "-" and delete anything to the right up to the ^. So i would the final product to look like this: Control of positive symptoms^ Q330R1 (1) Tolerability/ side effects^ Q330R2(1) Durability (ability to control symptoms from one injection to the next)^Q330R3 (1) Dosing schedule (frequency of dosing – 4 or 6 weeks)^Q330R4 (1) I tried using the recorder but that did not help me and i know how to do simple find and replace macros when it comes to fonts and styles but this one i could not figure out. Any help would be appreciated. |
#2
|
|||
|
|||
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 11/20/2017 Dim oRng As Range Set oRng = ActiveDocument.Range oRng.InsertBefore vbCr With oRng.Find .Text = "([^13^11])(*): " .MatchWildcards = True .Replacement.Text = "\1" .Execute Replace:=wdReplaceAll End With Set oRng = ActiveDocument.Range With oRng.Find .Text = " -*(^^)" .MatchWildcards = True .Replacement.Text = "\1" .Execute Replace:=wdReplaceAll End With ActiveDocument.Paragraphs(1).Range.Delete lbl_Exit: Exit Sub End Sub |
#3
|
||||
|
||||
You could try using a wildcard Find/Replace, where:
Find = ^13*: (*)\-*([^94]) Replace = ^p\1\2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thank you gmaxey and macropod! Both of these solutions worked for me. Thank you again for your help with this!
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
finding 'struck-through' text | joebloggs | Word | 1 | 08-16-2017 10:27 PM |
Inserting Symbols and Keeping Text Aligned- THANK YOU! | StuartS | Word | 1 | 07-21-2016 10:00 PM |
Finding the nth Blank Value in a Row of Text | ljg713 | Excel | 7 | 01-12-2016 07:49 AM |
symbols beside text like in onenote? | symbolgirl | Word | 3 | 04-20-2012 01:44 AM |
text changes to symbols | EMAW 2010 | Word | 4 | 03-25-2010 12:32 PM |