Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-01-2014, 12:24 PM
VeeCee VeeCee is offline Remove text between two words Windows XP Remove text between two words Office 2007
Novice
Remove text between two words
 
Join Date: Jan 2014
Posts: 4
VeeCee is on a distinguished road
Default Remove text between two words

I have a large document of lab results where values are displayed in lines. Some of them give comments following the results. They usually start as "interpretation.......... values". The first and the last words are usually the same. What is in between the words can be different.



Find and replace works only for characters or words. Is there a macro that can speed up to remove the comments by choosing the first and last word in the document?

Any help greatly appreciated.
Reply With Quote
  #2  
Old 01-01-2014, 01:50 PM
macropod's Avatar
macropod macropod is offline Remove text between two words Windows 7 32bit Remove text between two words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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 use a wildcard Find/Replace, where:
Find = [Ii]nterpretation*values
Replace = whatever you want to replace the text with
No code required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-02-2014, 02:58 PM
VeeCee VeeCee is offline Remove text between two words Windows XP Remove text between two words Office 2007
Novice
Remove text between two words
 
Join Date: Jan 2014
Posts: 4
VeeCee is on a distinguished road
Exclamation Remove text between two words

Dear Macropod,

Thank you. I am not sure whether I made my query clear. As mentioned I can find a word and replace it. What I want is to remove a sentence or paragraph between two words. Egs:

26-Jun-2013 ! HbA1c levl - IFCC standardised 87 mmol/molHb
Interpretation
~
IFCC HbA1C < 48 Good control;
IFCC HbA1C 48-64 Acceptable control;
IFCC HbA1C >64 Inadequate control, review medication.
IFCC - International Federation of Clinical Chemistry
and Laboratory Medicine.
Please visit www.diabetes.nhs.uk/ for details.
DCTT HbA1c 6.5% = IFCC HbA1c 48 mmol/mol;
DCTT HbA1c 7.5% = IFCC HbA1c 58 mmol/mol;
DCTT HbA1c 8.0% = IFCC HbA1c 64 mmol/mol;
DCTT HbA1c 9.0% = IFCC HbA1c 75 mmol/mol


26-Jun-2013 GFR calculated abbreviatd MDRD 57 Units:mL/min/1.73m^2
[I]Multiply eGFR by 1.21 for people of African
Caribbean origin. Interpret with regard to
UK CKD guidelines:www.renal.org/CKDguide/ckd.html
26-Jun-2013 Serum triglycerides 1.9 mmol/L

I like to remove everything between and including "Interpretation ......75 mmol/mol" and "Multiply.....ckd.html". I want to keep what is displayed in Magenta.

In find and replace I do not think I can paste a paragraph. I am not an expert so apologies for my ignorance.
Reply With Quote
  #4  
Old 01-02-2014, 08:37 PM
macropod's Avatar
macropod macropod is offline Remove text between two words Windows 7 32bit Remove text between two words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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

For the scenarios such as you have posted, it appears you want to delete all paragraphs/lines that don't begin with a number (i.e. the day of the month). For that you could use a wildcard Find/Replace, where:
Find = [^13^l]*([^13^l][0-9])
Replace = \1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-05-2014, 08:16 AM
VeeCee VeeCee is offline Remove text between two words Windows XP Remove text between two words Office 2007
Novice
Remove text between two words
 
Join Date: Jan 2014
Posts: 4
VeeCee is on a distinguished road
Default Remove text between two words

Dear Macropod,

Thank you. Your suggestion can work in selected cases. Unfortunately my document has a mixture of valid entries witout a date and trying your suggestion ALL lines starting without a date get deleted. That is why i wanted to know whether there is a macro or some short cut to delete ALL entries between TWO words or characters.

Enclosed find my original document and the result after trying your method. I wanted to delete only the magents letters from the original. The text in magenta is variable and hence I should be able to chose the first and last word of the text I like to delete.

Thanks again for your efforts to help me.
Attached Files
File Type: doc Original.doc (41.0 KB, 12 views)
File Type: doc Result.doc (23.5 KB, 11 views)
Reply With Quote
  #6  
Old 01-05-2014, 01:29 PM
macropod's Avatar
macropod macropod is offline Remove text between two words Windows 7 32bit Remove text between two words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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

Quote:
Originally Posted by VeeCee View Post
Unfortunately my document has a mixture of valid entries witout a date and trying your suggestion ALL lines starting without a date get deleted. That is why i wanted to know whether there is a macro or some short cut to delete ALL entries between TWO words or characters.
Well, yes, but one needs to know beforehand what those words/characters are. In any event, a VBA solution would basically be a coded version of the wildcard Find/Replace expressions I've already been providing.

The wildcard Find/Replace expression could be made more specific. For example:
Find = [^13^l]*([^13^l][0-9]{1,2}-)
Replace = \1
will only act on those cases where a one/two digit number is followed by a hyphen (as you have with your dates). We could even add further sophistication to include the rest of the date in a wildcard form if necessary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 01-05-2014, 01:59 PM
VeeCee VeeCee is offline Remove text between two words Windows XP Remove text between two words Office 2007
Novice
Remove text between two words
 
Join Date: Jan 2014
Posts: 4
VeeCee is on a distinguished road
Default

Dear Macropod,

Thank you for pointing in the right direction. As mentioned, I do not know anything about VBA. I'll read up the meaning of [^13^l]*([^13^l][0-9]{1,2}-) and substitute the words in that expression to tackle the problem.

Thanks again for your guidance.
Reply With Quote
  #8  
Old 01-05-2014, 03:39 PM
macropod's Avatar
macropod macropod is offline Remove text between two words Windows 7 32bit Remove text between two words Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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

To delete all lines between lines that begin with a date in the DD-MMM-YYYY format, try a wildcard Find/Replace, where:
Find = [^13^l]*([^13^l][0-9]{1,2}-[JASOND][abceglnoprtuvy]{2}-[0-9]{4})
Replace = \1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove text between two words dotted lines under text -- how to remove? Straitsfan Word 1 11-11-2013 11:55 AM
Remove text between two words Need VBA For Macro On How To Remove Specific Words netchie Word VBA 6 08-28-2012 03:37 PM
How to remove 'gray background from text' tahirawan11 Word 1 09-05-2011 05:45 AM
Remove text between two words Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Remove text between two words Remove text in start up document Sheila Word 1 09-30-2010 03:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:12 AM.


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