![]() |
#1
|
|||
|
|||
![]()
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. |
#2
|
||||
|
||||
![]()
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] |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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] |
#5
|
|||
|
|||
![]()
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. |
#6
|
||||
|
||||
![]() Quote:
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] |
#7
|
|||
|
|||
![]()
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. |
#8
|
||||
|
||||
![]()
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] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Straitsfan | Word | 1 | 11-11-2013 11:55 AM |
![]() |
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 |
![]() |
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
![]() |
Sheila | Word | 1 | 09-30-2010 03:33 PM |