HI,
I have a quite large formula i use on a regular basis to reformat some data that comes out of our sql. i would like to create a udf from it in order to shorten the formula.
The formula is as follows:
=IF(SUMPRODUCT(LEN(A2)-LEN(SUBSTITUTE(A2,{1,2,3,4,5,6,7,8,9,0},"")))=0,"Invalid Postcode",IF(SUMPRODUCT(LEN(A2)-LEN(SUBSTITUTE(A2,{1,2,3,4,5,6,7,8,9,0},"")))>3,"invalid postcode",IF(LEN(SUBSTITUTE(A2," ",""))<5,"Invalid Postcode",IF(LEN(SUBSTITUTE(A2," ",""))>8,"Invalid Postcode",TRIM(CONCATENATE(UPPER(LEFT(SUBSTITUTE(A2," ",""),LEN(SUBSTITUTE(A2," ",""))-3))," ",UPPER(RIGHT(SUBSTITUTE(A2," ",""),3))))))))
I'm not a complete novice with VBA, but would just like a little guidance on how to go about creating UDF's.
Thanks,
Dan.
I have a quite large formula i use on a regular basis to reformat some data that comes out of our sql. i would like to create a udf from it in order to shorten the formula.
The formula is as follows:
=IF(SUMPRODUCT(LEN(A2)-LEN(SUBSTITUTE(A2,{1,2,3,4,5,6,7,8,9,0},"")))=0,"Invalid Postcode",IF(SUMPRODUCT(LEN(A2)-LEN(SUBSTITUTE(A2,{1,2,3,4,5,6,7,8,9,0},"")))>3,"invalid postcode",IF(LEN(SUBSTITUTE(A2," ",""))<5,"Invalid Postcode",IF(LEN(SUBSTITUTE(A2," ",""))>8,"Invalid Postcode",TRIM(CONCATENATE(UPPER(LEFT(SUBSTITUTE(A2," ",""),LEN(SUBSTITUTE(A2," ",""))-3))," ",UPPER(RIGHT(SUBSTITUTE(A2," ",""),3))))))))
I'm not a complete novice with VBA, but would just like a little guidance on how to go about creating UDF's.
Thanks,
Dan.