Excel - Automatically change text in column

Ask a question




Issue

I want to search the column A, with numbers as text as follows:
#305  
#777
#78
#82
#884


I need a formula that will search column A and change any two digit numbers to three digit with a leading zero.


I want the change to take place within the existing data in column a so that example data:

a1 lkjljlk blah #305  
a2 dkfjalfj blah #55


would end up as

a1 lkjljlk blah #305  
a2 dkfjalfj blah #055

Solution

Suppose A1 to A5 is
305  
777
78
82
884


In B1 type this formula:

=IF(LEN(A1)=2,"0"&A1,A1) 
  • copy B1 down
  • highlight B1 down
  • edit copy
  • highlight B1 only
  • edit -pastespecial-choose values and click ok
  • now delete column A


Do this as an experiment and you will get hang of it.

Note

Thanks to venkat1926 for this tip on the forum.
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team