View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Peo Sjoblom[_2_] Peo Sjoblom[_2_] is offline
external usenet poster
 
Posts: 964
Default User Defined FUNCTION

Why would you even use SUBSTITUTE?

=IF(AND(LEN(A1)=8,RIGHT(TRIM(A1),4)="0000"),TRUNC( A1,4)/10000,A1)


--


Regards,


Peo Sjoblom

"EAK" wrote in message
...
I need a User Defined Function that check if a number or string is 8 digits
long and ends in "0000". If it meets the two creteria, then it should drop
those the "0000" and return only the remaining 4 numbers for example,

23000016 result 23000016
23160000 result 2316
19000000 result 1900

FYI using Substitute() gives me the wrong result sometimes.

FUNCTION Truc(location)

END Function