Follow via:
RSS
Email Alert
Question
0 Votes
+ -

Excel : Leading Zeros in Formulas

To best simulate, input the following....
A2 = 021
B2 = 05

A3 = update product_code = 'A2' where id_code = 'B2'

I have formated each cell as custom "000" for A2, "00" for B2. This is to ensure that by typing 5 in B2, I will get 05, which is the correct format I need.

If you enter in the formula seen in A3, the leading zeros drop, I need the leading zeros there. What am I do wrong?
Tags: software, excel
25th Mar 2008

Answers (1)

0 Votes
+ -
Example...
Problem:

Column A (List1) is formatted to display a leading zero before each number. That is, "1" is displayed as "01", "2" as "02", and so on.
The following formula was created to concatenate the numbers from List1 into one string:
=A2&A3&A4&A5
However, an incorrect result of "1234" is returned.
How can we modify the formula to honor the leading zeros?

Solution:

Use the TEXT function as shown in the following formula:
=TEXT(A2,"00")&TEXT(A3,"00")&TEXT(A4,"00")&TEXT(A5,"00")
I hope this gives you a clue..

Please post back if you have anymore problems or questions.
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.