Originally Posted by
FlameRetired
The first part =IF(LEFT(A2,5)="00971",MID(A2,3,99),IF(LEFT(A2,2)="05",971&MID(A2,2,99),A2)) tests the value to see if the 5 LEFTmost characters
are "00971"; if they are the MID function, starting at character position 3, returns the balance of the string. 99 is an arbitrarily large number that is likely to go
beyond the end of the string.
The second part =IF(LEFT(A2,5)="00971",MID(A2,3,99),IF(LEFT(A2,2)="05",971&MID(A2,2,99),A2)) says that if it is not "00971" then test if the
2 LEFTmost characters are "05"; if they are then MID starts at character position 2 and behaves as in the first part. If neither condition is true then the string
must be OK, so it returns the original string =IF(LEFT(A2,5)="00971",MID(A2,3,99),IF(LEFT(A2,2)="05",971&MID(A2,2,99),A2)).
Does this help?
Bookmarks