Forum

Notifications
Clear all

Excel formula help

7 Posts
3 Users
0 Reactions
121 Views
(@viking)
Posts: 3
Active Member
Topic starter
 

Hi there,

 

so I have a column with 9 or 10 numbers in each cell. 

i need to add a 0 (zero) only in front of the cells containing 9 numbers . 

does anyone know an excel formula for this? 

Thanks,

 
Posted : 22/11/2019 1:41 pm
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Anne

You can try =TEXT(A1,"0000000000")

It works for both 9 or 10 digit numbers.

Please note that this will convert the numbers to text.

Otherwise you can custom format the cells with 0000000000 (10 zeroes)

Hope this helps.

Sunny

 
Posted : 22/11/2019 11:46 pm
(@viking)
Posts: 3
Active Member
Topic starter
 

Thank you. 
this text formula works to add a 0 to all numbers, but not to the ones only containing 9 numbers. I don’t need a 0 in front of the cells with 10 numbers in it.  Is there a formula for this? 

 
Posted : 23/11/2019 1:36 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Anne,

The formula above won't add a 0 in front of numbers that contain 10 digits. Perhaps you can share your file so we can troubleshoot.

Mynda

 
Posted : 23/11/2019 5:55 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Anne

I suspect you keyed 11 zeroes instead of 10 in your formula.

The formula will only add a zero to the front of numbers with 9 or less digits.

Same with the custom formatting.

Sunny

 
Posted : 24/11/2019 12:31 am
(@viking)
Posts: 3
Active Member
Topic starter
 

Thanks for your responses. And I have to apologise, because the cells I need a zero in front of has 10 numbers ,not 9.

the cells I don’t need a zero in front of , has 9 numbers in it. 
It’s the opposite of what I said earlier . 

these are all in the same column. 

Ive tried the text formula and if I apply it to the 10 number cells, and copy the formula down , it will also give a zero in front of the cells with 9 numbers, which i don’t need. 
so I suspect I need a type of IF formula ?

 
Posted : 27/11/2019 12:39 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Anne,

Yes, an IF will work. The formula below will convert both 9 and 10 digit numbers to text:

=IF(LEN(A1)=9,TEXT(A1,"000000000"),TEXT(A1,"00000000000"))

If you're happy with a mix of numbers and text in the column then you can use this:

=IF(LEN(A2)=9,A1,TEXT(A1,"00000000000"))

Although I would encourage you to have consistent values, therefore the first formula would be best.

Mynda

 
Posted : 27/11/2019 5:57 pm
Share: