View Single Post
 
Old 06-04-2019, 05:26 PM
Chayes Chayes is offline Windows 7 32bit Office 2003
Advanced Beginner
 
Join Date: May 2012
Posts: 79
Chayes is on a distinguished road
Default VBA for selecting given text and moving the whole line

Hi All


I have some text in which I'd like to select certain given text , and then place a return above and below so that the whole line it is in is isolated.



For example , the code would find and make bold every line in which the word 'Wrote:' is found in the text below , then put returns above and below :


Original

------------------------------------------------------------

On Tue, May 21, 2019 at 2:54 PM <wrote:
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
On 20/05/2019 15:41,wrote:
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
On 15/05/2019 16:03,wrote:
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random


------------------------------------------------------------


After the running the code it would read :


----------------------------------------------------------



On Tue, May 21, 2019 at 2:54 PM <wrote:

Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random


On 20/05/2019 15:41,wrote:

Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random


On 15/05/2019 16:03,wrote:

Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random
Random Text Random Text Random Text Random

--------------------------------------------------


Clearly the amount of occurrences of the chosen text could vary , and this gives an added complication.


Very grateful for any advice on this one. I've attached a sample file.



Thanks.
Attached Files
File Type: doc Sample3.doc (22.5 KB, 5 views)
Reply With Quote