View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Create new function

Yes.


You can create your own functions (call UDFs) in Visual Basic.
--
Gary''s Student


" wrote:

Is it possible to create a function to use in formulas?

I had a function the other day that got quite large as I had to repeat
the same functionality. I would have liked to been able to do
something like:

=IF(<Cell="","",IF(ISTEXT(<Cell),IF(LEN(<Cell) 6,RIGHT(<Cell,4),"----")&"/"&LEFT(<Cell,myfunc1(<Cell)-1)&"/"&MID(<Cell,myfunc1(<Cell)+1,SEARCH("/",<Cell,myfunc1(<Cell)+1)-myfunc1(<Cell)-1),TEXT(<Cell,"yyyy/mm/dd")))


instead of

=IF(<Cell="","",IF(ISTEXT(<Cell),IF(LEN(<Cell) 6,RIGHT(<Cell,4),"----")&"/"&LEFT(<Cell,SEARCH("/",<Cell,1)-1)&"/"&MID(<Cell,SEARCH("/",<Cell,1)+1,SEARCH("/",<Cell,SEARCH("/",<Cell,1)+1)-SEARCH("/",<Cell,1)-1),TEXT(<Cell,"yyyy/mm/dd")))

(although this example wasn't that large, It grew from this)

If it is possible to create my own function, I would like to be able to
reference other cells in the function. For example, myfunc1 may need
to look at the the column preceding the cell reference. Is this even
possible?

Thanks.