Adding hyphen to text in cell

P

Penny

I would like to add a hypen to the text that exists on the excel sheet. Is
there a formula for this?

example of text on sheet without hypen:
G212DA

text with hypen:
G-212DA
 
A

Alan

Assuming you always want the hyphen after the first character,

=LEFT(A1,1)&"-"&RIGHT(A1,(LEN(A1)-1))

Regards,
Alan.
 
C

Chip Pearson

Try

=LEFT(A1,1)&"-"&MID(A1,2,999)

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
M

mePenny

My mistake.. not all need it after the first character. I also need after
second:

example:
GA02004
Example:
GA-02004
 
A

Alan

Change the formula to,

=LEFT(A1,2)&"-"&RIGHT(A1,(LEN(A1)-2))

You could enter where you want the hyphen in an adjacent cell, if you enter
1 in B1

=LEFT(A1,B1)&"-"&RIGHT(A1,(LEN(A1)-B1))

will give you G-212DA, enter 2 and you have G2-12DA

Regards,
Alan.

But
 
A

Alan

That's good. If you want to make the result permanent, ie lose the formulas,
highlight the whole range, right click 'Copy', right click again, 'Paste
Special', check 'Values', OK.
You can then copy and paste the list to overwrite the original list. Best to
do this in a copy of the workbook.
Regards,
Alan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top