Create new function
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. |
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. |
All times are GMT +1. The time now is 08:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com