The function below is what I use to handle contact information (email/phone numbers). If the entry is an email id (has text), it will keep it as is. When a phone number is entered, it does a variety of things to it.
=IF(ISNUMBER(E2), IF(LEFT(E2, 2) = "44", REPLACE(E2,1,2,"0"), CONCAT("0",E2)), E2)
I am trying to add the code/function below to the phone number before Google Sheets applies the above formula.
=REGEXREPLACE(TEXT(E2,"##############"),"\D","")
Basically, if cell E2 is a number, then I want to REGEXREPLACE
that number first, and then perform the additional operations. I'm not sure how to join the two formulas.
You may have a look at the expected output, and test your formulas here: spreadsheet sample
Best Answer
IF
statement consists of 3 parts. understanding how it works:if (something is something, do this, if not - do this)
so in formula expression:
=IF(E2="something", "its ok, do nothing", "E2 isn't ""something"" do something")
things get confusing if you want to do more advanced things, however, 3-part rule always remains
solution 1:
=REGEXREPLACE(TEXT(A3,"##############"),"\D","")
=IF(B3="",A3, IF(LEFT(B3, 2) = "44", REPLACE(B3,1,2,"0"), CONCAT("0",B3)))
solution 2:
why it didn't work for you:
cells A7, A9 and A11 are in your sheet formatted as
TEXT
and not asNUMBER
while your formula claimed=IF(ISNUMBER(...etc.
so returning value was equal to the original/initial value.