Hi, I'm having some problems with this formula due to its length at the moment I've got P3 as the target however it should be Datasheet!B6 but doing this throws it way over the limit so I wondered if anyone could help me shorten it?

Basically the formula is taking the 2nd octet from a IP address and adding leading zeros if its only 1 or 2 characters long.

IF(LEN((MID(MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256),2,FIND(".",MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256))-2)))=1,"00"& (MID(MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256),2,FIND(".",MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256))-2)),IF(LEN((MID(MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256),2,FIND(".",MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256))-2)))=2,"0"& (MID(MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256),2,FIND(".",MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256))-2)),(MID(MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256),2,FIND(".",MID(MID(SUBSTITUTE(P3,".","^",1),1,256),FIND("^",SUBSTITUTE(P3,".","^",1)),256))-2))))