How to insert multiple characters in middle of cell data

horizont

New Member
Joined
Mar 9, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I need to insert two "-" into a column of cells in different locations within the same number. What is the best way to do this?
I have figured out how to get one of the hyphens in using the formula =REPLACE(A2,7,0,"-") but I can't figure out how to get the second hyphen in.

Example:
Existing information in cell:
123456789

Needs to be:
123456-78-9

Thanks for all you help!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Is the data always 9 characters?

Excel Formula:
=LEFT(A2,6) & "-" & MID(A2,7,2) & "-" & RIGHT(A2,1)
 
Upvote 0
Another option
Excel Formula:
=REPLACE(REPLACE(A2,9,0,"-"),7,0,"-")
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,047
Members
448,940
Latest member
mdusw

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