Solved

# If Expression in Excel

Posted on 2012-08-17

Can any one please help me understand this below Expression.. especially the IF part

=RIGHT(G4,LEN(G4)-IF(OR(MID(G4,1,1)="0",MID(G4,1,1)="9"),

IF(OR(MID(G4,2,1)="0",MID(G4,2,1)="1"),

IF(OR(MID(G4,3,1)="0",AND(MID(G4,3,1)="1",MID(G4,1,3)<>"001"),MID(G4,1,3)="900"),

IF(OR(MID(G4,4,1)="0",MID(G4,1,4)="9011",AND(MID(G4,1,5)="00021",LEFT(R4,2)="BR")),

IF(OR(MID(G4,5,1)="0",AND(MID(G4,1,5)="00021",LEFT(R4,2)="BR")),

IF(MID(G4,6,1)="0",6,5),4),3),2),1),0))

As i understand

1st IF - looking to see if 1st character is 0 or 9 then remove 1st character from the string

2nd IF - if 2nd charcter is 0 or 1 Then remove 1st 2 characters from the string

3rd IF - if 3rd char is 0 or (3rd char is 1 and 1st 3 characters = 001) or 1st 3 chars = 900 then remove 1st 3 chars from the string

Ex: 00039019746598 should result in 39019746598

Is that right? appreciate your help