VBA to enter three spaces after a period

kreepa

Board Regular
Joined
Mar 24, 2005
Messages
57
I was transferring some data from Excel to Word. Sometimes this data goes onto legal files so I need the spacing and punctuation to be crisp and presentable.

I know it is something like:

ActiveDocument.Content.Select if(count of blank <> 3 adjust it to 3).
TypeText Text:=" "

I hope this makes since to someone. I have the outline, I just can't string it together.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I think the easiest way would be firstly to reduce all spaces to one, e.g. B1=Trim(A1) and then use substitute(B1," "," "), or combining them substitute(Trim(A1)," "," "). I don't do VB but I imagine this would would be simple to convert, if not paste it after each cell/line in Excel
 
Upvote 0
The problem I see if that you do not want ALL periods to have 3 spaces after them, or do you. For instance "Mr. John Doe" versus "...end of the line. Next sentance...". If you did want 3 spaces after EVERY period. You could have a simple macro that replaced period + space with just a period and have that loop a couple times and then replace all period's with a period + 3 spaces. Or conversely, have a macro that replaced all period's with a period + 3 spaces and then have a loop to replace all instances of 4 spaces with 3 spaces. Neither approach is good, but would work...
 
Upvote 0

Forum statistics

Threads
1,225,345
Messages
6,184,394
Members
453,229
Latest member
Piip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top