Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2017, 11:18 PM
Tomperm Tomperm is offline Add dashes to each line of a list Windows 7 64bit Add dashes to each line of a list Office 2013
Novice
Add dashes to each line of a list
 
Join Date: Feb 2017
Posts: 2
Tomperm is on a distinguished road
Default Add dashes to each line of a list

Hello,

I have a list of IDs containing 32 characters and I need to format them in a certain way, namely to add dashes “-“ after the 8th, 12th, 16th, and 20th characters. So my question is: is there any way to format like this en masse because I obviously can’t add the dashes manually for the thousands of IDs I have.

Here’s an example:
Current ID -> 0DA88BE61C864A99BE730EEE81D82FCC
Needed ID -> 0DA88BE6-1C86-4A99-BE73-0EEE81D82FCC

I’d appreciate any help for this.



Thanks,
Tom
Reply With Quote
  #2  
Old 02-13-2017, 11:51 PM
gmayor's Avatar
gmayor gmayor is offline Add dashes to each line of a list Windows 10 Add dashes to each line of a list 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

Use a replacement of:
([0-9A-Z]{8})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{12})
with
\1-\2-\3-\4-\5
with the wildcard option set - http://www.gmayor.com/replace_using_wildcards.htm
or by macro

Code:
Sub Macro1()
Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="([0-9A-Z]{8})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{12})", _
                          MatchWildcards:=True, ReplaceWith:="\1-\2-\3-\4-\5")
            oRng.Collapse 0
        Loop
    End With
End Sub
__________________
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 02-15-2017, 05:48 PM
Tomperm Tomperm is offline Add dashes to each line of a list Windows 7 64bit Add dashes to each line of a list Office 2013
Novice
Add dashes to each line of a list
 
Join Date: Feb 2017
Posts: 2
Tomperm is on a distinguished road
Default

Worked like a charm!

Thanks, Graham.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add dashes to each line of a list Search+replace all --- [3 dashes] with square wingding imported_contiw Word 14 10-04-2017 01:03 PM
Numbered list and one row table to appear on same line jsukan Word Tables 1 04-09-2015 01:04 AM
Add dashes to each line of a list changing colons into dashes retrofan Word 2 07-27-2014 05:05 AM
letters are dashes pmd Word 5 03-05-2012 08:08 PM
Why word does not wrap on dashes? lyrebird Word 3 06-23-2010 01:32 AM

Other Forums: Access Forums

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