Add zero to beginning of number extraction

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
322
Office Version
  1. 365
Platform
  1. Windows
Hello peeps,

I have a formula to extract the first number from the previous cell and would like to add a "0" in formula if one hasn't been entered previously.
¦ MrExcel Queries.xlsm
ABC
1Contact NumberNumberText
201111 11111101111 11111
301111 111111 (sister's number)01111 11111(sister's number)
411111111111111111111
Sheet3
Cell Formulas
RangeFormula
B2:B4B2=LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9"},""))))

Any help would be appreciated :)
 
Just been having a play with the other formulas, and they all work (except for one CF)! So an extra big thanks to you all! :biggrin:
¦ MrExcel Queries.xlsm
ABCDEFG
1Contact NumberNumberWould like!Text@PeteWright@MARK858@Scott Huish
201111 22233301111 22233301111 22233301111 22233301111 222333
301111 222333 (sister's number)01111 222333(sister's number)01111 22233301111 22233301111 222333
41111222333111122233301111 2223330111122233301111 22233301111 222333
Extract number
Cell Formulas
RangeFormula
E2:E4E2=IFERROR(IF(NUMBERVALUE(LEFT(A2))<>0,"0"&LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9","0"},"")))),LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9","0"},""))))),A2)
F2:F4F2=TEXT(IFERROR(IF(NUMBERVALUE(LEFT(A2))<>0,"0"&LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9","0"},"")))),LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9","0"},""))))),A2),"0#### ######")
G2:G4G2=IFERROR(TEXT(MAX(--MID(SUBSTITUTE(A2," ",""),1,SEQUENCE(11))),"00000 000000"),"")
B2:B4B2=LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9","0"},""))))

Wish I could mark you all as the solution, but will do @MARK858 because he got there first (even though I'm going to use @Scott Huish! ;) )...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,004
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top