Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2019, 07:24 PM
Helend269 Helend269 is offline Inserting blank lines but only once no matter how many times code is run Windows 7 32bit Inserting blank lines but only once no matter how many times code is run Office 2003
Novice
Inserting blank lines but only once no matter how many times code is run
 
Join Date: Aug 2017
Posts: 15
Helend269 is on a distinguished road
Default Inserting blank lines but only once no matter how many times code is run

I have lines of text and I want to use VBA to insert blank lines but only once, no matter how many times I run the code. So:




This is line one.
This is line two.



Becomes:
This is line one.


This is line two.





I have a find/replace that searches for".^p[A-Z]" and replaces it with ".^p^p[A-Z]". The [A-Z] is supposed to find any capital letter on the next line and replace it with the same capital letter.



If my find /replace is ".^p" / ".^p^p" then running it again will insert a blank line each time I run it. Having it look for a capital letter after the ".^p" will prevent that.


But when I run it nothing happens. Is what I want to do possible?




Thank you.
Reply With Quote
  #2  
Old 08-19-2019, 08:23 PM
gmayor's Avatar
gmayor gmayor is offline Inserting blank lines but only once no matter how many times code is run Windows 10 Inserting blank lines but only once no matter how many times code is run Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Search for
([!^13]^13)([A-Z])
with the wildcard option set
Replace with
\1^p\2
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 08-19-2019, 09:41 PM
Helend269 Helend269 is offline Inserting blank lines but only once no matter how many times code is run Windows 7 32bit Inserting blank lines but only once no matter how many times code is run Office 2003
Novice
Inserting blank lines but only once no matter how many times code is run
 
Join Date: Aug 2017
Posts: 15
Helend269 is on a distinguished road
Default

That did it. Brilliant! Thank you! I knew it was something along those lines but I couldn't quite get there.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax for inserting blank line before inserting table and after a line or paragraph SamDsouza Word VBA 8 08-04-2019 11:10 PM
Inserting blank lines but only once no matter how many times code is run vba code for folder name, subfolder directory, file name & revision times klpw Excel Programming 2 12-24-2015 12:31 AM
Inserting blank lines but only once no matter how many times code is run Inserting blank columns Guloluseus Excel 2 06-24-2015 09:07 AM
Inserting blank lines but only once no matter how many times code is run Getting blank lines instead of supressed lines. Welshie82 Mail Merge 2 11-14-2011 01:41 AM
Inserting blank lines but only once no matter how many times code is run How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:05 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