Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add leading zero to number in text string 1

Status
Not open for further replies.

chasethewind

Technical User
Oct 29, 2004
63
US
I'm looking for an easy solution to add a leading zero to a text string in excel 2010.

There is the text string:

N5^43'W
it should say
N05^43'W

or

S6^7'E
should say
S06^07'E

Thanks
 
Just use find and replace.

Find "N", replace with "N0"
Find "S", replace with"S0
 
That wouldn't return the correct value on some cases.

I would end up with "N032^45'E
on
N32^45'E
 
hi,

Just text formulas like FIND, LEN, MID. Nothing magic.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
And I was supposed to know that there are cases different from your examples how?
 
this may not be easy but it seems to work on the data set you created and some corner cases I added...

=CONCATENATE(LEFT(E3,1),TEXT(MID(E3,2,FIND("^",E3,1)-2),"00"),"^",TEXT(MID(E3,FIND("^",E3)+1,FIND("'",E3)-FIND("^",E3)-1),"00"),"'",RIGHT(E3,1))

this assumes your data is in column E and the formula I put in column G

Hope this helps

Ernest

Be Alert, America needs more lerts
 
Thanks Judgeh59, that was exactly what I was after.

Solved
 
hey chase,

Over the past 8 years you have posted many questions and received many helpful replies from Tek-Tip members. Yet, you have NEVER posted a customary "THANK YOU" for these valuable posts.

Since the solution posted by "Judgeh59, that was exactly what I was after," it would be most fitting to...

[blue]
Thank judgeh59
for this valuable post!
[/blue]

These [purple]Little Purple Stars[/purple] identify threads for Tek-Tips browsers, as ones that have been helpful. They also act as a token "Thank You" to the one or ones who posted valuable information. And they identify the recipient as a grateful member.


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
you're welcome Sir

Ernest

Be Alert, America needs more lerts
 
Skip,
It is pretty bad if you have to ‘squeeze’ some kind of token of appreciation for the help provided over the years. Pretty sad…
:-(

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top