Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2017, 12:43 PM
llcriticll llcriticll is offline Finding Symbols And Deleting Text Before And After It Windows XP Finding Symbols And Deleting Text Before And After It Office 2010 64bit
Novice
Finding Symbols And Deleting Text Before And After It
 
Join Date: Nov 2017
Posts: 2
llcriticll is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 11-20-2017, 03:04 PM
gmaxey gmaxey is offline Finding Symbols And Deleting Text Before And After It Windows 7 32bit Finding Symbols And Deleting Text Before And After It Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-20-2017, 03:07 PM
macropod's Avatar
macropod macropod is offline Finding Symbols And Deleting Text Before And After It Windows 7 64bit Finding Symbols And Deleting Text Before And After It Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

You could try using a wildcard Find/Replace, where:
Find = ^13*: (*)\-*([^94])
Replace = ^p\1\2
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-21-2017, 05:11 AM
llcriticll llcriticll is offline Finding Symbols And Deleting Text Before And After It Windows XP Finding Symbols And Deleting Text Before And After It Office 2010 64bit
Novice
Finding Symbols And Deleting Text Before And After It
 
Join Date: Nov 2017
Posts: 2
llcriticll is on a distinguished road
Default

Thank you gmaxey and macropod! Both of these solutions worked for me. Thank you again for your help with this!
Reply With Quote
Reply

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
Finding Symbols And Deleting Text Before And After It Inserting Symbols and Keeping Text Aligned- THANK YOU! StuartS Word 1 07-21-2016 10:00 PM
Finding Symbols And Deleting Text Before And After It Finding the nth Blank Value in a Row of Text ljg713 Excel 7 01-12-2016 07:49 AM
Finding Symbols And Deleting Text Before And After It symbols beside text like in onenote? symbolgirl Word 3 04-20-2012 01:44 AM
Finding Symbols And Deleting Text Before And After It text changes to symbols EMAW 2010 Word 4 03-25-2010 12:32 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:39 AM.


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