I need a formula in excel with if condition.

if the mail id abcd@xyz.com then the result should come as XYZ, if the mail id is abcd@.in.xyz.com then the result should come as XYZ.

result should be XYZ if any of the above mail id is there.

for the first one i got the formula as if mail id is in C2 then the formula is as

```
UPPER(SUBSTITUTE(LEFT(MID(C2,FIND("@",C2)+1,LEN(C2)),FIND(".",MID(C2,FIND("@",C2)+2,LEN(C2)))),"."," "))
```