close

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(lt;Cellgt;=quot;quot;,quot;quot;,IF(ISTEXT(lt;Cellgt;),IF(LEN(lt;Cellgt;)gt; 6,RIGHT(lt;Cellgt;,4),quot;----quot;)amp;quot;/quot;amp;LEFT(lt;Cellgt;,myfunc1(lt;Cellgt;)-1)amp;quot;/quot;amp;MID(lt;Cellgt;,myfunc1(lt;Cellgt;) 1,SEARCH(quot;/quot;,lt;Cellgt;,myfunc1(lt;Cellgt;) 1)-myfunc1(lt;Cellgt;)-1),TEXT(lt;Cellgt;,quot;yyyy/mm/ddquot;)))instead of

=IF(lt;Cellgt;=quot;quot;,quot;quot;,IF(ISTEXT(lt;Cellgt;),IF(LEN(lt;Cellgt;)gt; 6,RIGHT(lt;Cellgt;,4),quot;----quot;)amp;quot;/quot;amp;LEFT(lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1)-1)amp;quot;/quot;amp;MID(lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1) 1,SEARCH(quot;/quot;,lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1) 1)-SEARCH(quot;/quot;,lt;Cellgt;,1)-1),TEXT(lt;Cellgt;,quot;yyyy/mm/ddquot;)))

(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.Yes.You can create your own functions (call UDFs) in Visual Basic.
--
Gary''s Studentquot; wrote:

gt; Is it possible to create a function to use in formulas?
gt;
gt; I had a function the other day that got quite large as I had to repeat
gt; the same functionality. I would have liked to been able to do
gt; something like:
gt;
gt; =IF(lt;Cellgt;=quot;quot;,quot;quot;,IF(ISTEXT(lt;Cellgt;),IF(LEN(lt;Cellgt;)gt; 6,RIGHT(lt;Cellgt;,4),quot;----quot;)amp;quot;/quot;amp;LEFT(lt;Cellgt;,myfunc1(lt;Cellgt;)-1)amp;quot;/quot;amp;MID(lt;Cellgt;,myfunc1(lt;Cellgt;) 1,SEARCH(quot;/quot;,lt;Cellgt;,myfunc1(lt;Cellgt;) 1)-myfunc1(lt;Cellgt;)-1),TEXT(lt;Cellgt;,quot;yyyy/mm/ddquot;)))
gt;
gt;
gt; instead of
gt;
gt; =IF(lt;Cellgt;=quot;quot;,quot;quot;,IF(ISTEXT(lt;Cellgt;),IF(LEN(lt;Cellgt;)gt; 6,RIGHT(lt;Cellgt;,4),quot;----quot;)amp;quot;/quot;amp;LEFT(lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1)-1)amp;quot;/quot;amp;MID(lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1) 1,SEARCH(quot;/quot;,lt;Cellgt;,SEARCH(quot;/quot;,lt;Cellgt;,1) 1)-SEARCH(quot;/quot;,lt;Cellgt;,1)-1),TEXT(lt;Cellgt;,quot;yyyy/mm/ddquot;)))
gt;
gt; (although this example wasn't that large, It grew from this)
gt;
gt; If it is possible to create my own function, I would like to be able to
gt; reference other cells in the function. For example, myfunc1 may need
gt; to look at the the column preceding the cell reference. Is this even
gt; possible?
gt;
gt; Thanks.
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()