How Can I Insert a Character within Existing Cells?

copyboy007

Board Regular
Joined
May 17, 2005
Messages
64
Office Version
  1. 2016
Platform
  1. Windows
I have a column of 10-digit numbers (some fewer than 10; some more than 10). The format of the cells is general.

How can a dash ('-') be inserted after the sixth digit for the whole column? Would it be via a macro?
 

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.
Does this help?
Excel Workbook
ABC
1My NumbersNumber LengthConverted
2321654999910321654-9999
36549878889654987-888
41594877779159487-777
5357159668357159-66
Sheet1
Excel 2007
Cell Formulas
RangeFormula
B2=LEN(A2)
B3=LEN(A3)
B4=LEN(A4)
B5=LEN(A5)
C2=LEFT(A2,6) &"-" & MID(A2,7,99)
C3=LEFT(A3,6) &"-" & MID(A3,7,99)
C4=LEFT(A4,6) &"-" & MID(A4,7,99)
C5=LEFT(A5,6) &"-" & MID(A5,7,99)
 
Upvote 0
Also, with the numbers in column A starting in A2, in B2:

=REPLACE(A2,7,0,"-")

Copy down
 
Upvote 0
One more way:

=REPLACE(A2,6,1,MID(A2,6,1)&"-")

Regards

I tried this one, which worked perfectly.

One more parameter just given is to restrict this to just the cells containing ten digits. How can I exclude the others?
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

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