+ Reply to Thread
Results 1 to 10 of 10

Need to make a UDF from a long formula

  1. #1
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Need to make a UDF from a long formula

    Hi I have two long formulas that I want to make into a UDF so that it's easy to work with.

    The first formula calculates the duration in Frames per seconds from two time codes is:
    =("0:"&TEXT(DOLLARFR(ROUND(((LEFT(D3,8)*(86400*30)+RIGHT(D3,2))-(LEFT(B3,8)*(86400*30)+RIGHT(B3,2))),0)/30,30),"0.00"))+0

    I want to have a function that asks the user for the start time and end time

    THe second formula adds the total duration:
    =SUMPRODUCT(FLOOR(F3:F4,"0:1.0"))+("0:"&TEXT(DOLLARFR(SUMPRODUCT(ROUND(MOD(F3:F4*86400,1)*100,0))/30,30),"0.00"))

    I want an argument that prompts for the range to be added.

    I tried making the function with parameters and kept getting #Value as my result.

    I did:

    Public Function frameDur(fStart, fEnd)

    frameDur=("0:"&TEXT(DOLLARFR(ROUND(((LEFT(fEnda,8)*(86400*30)+RIGHT(fEnd,2))-(LEFT(fStart,8)*(86400*30)+RIGHT(fStart,2))),0)/30,30),"0.00"))+0

    End Function


    for each function I added Application.WorksheetFunction.(Function Name) and that didn't help.

    Any help would greatly be appreciated.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Need to make a UDF from a long formula

    on your first left there is fEnda....should that be fEnd?

    EDIT: in the Public Function....
    Last edited by judgeh59; 06-14-2013 at 05:14 PM. Reason: Incompeted Data
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Need to make a UDF from a long formula

    yes fEnd I was typing really fast on here.

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Need to make a UDF from a long formula

    but it's correct in the actual code?....

  5. #5
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Need to make a UDF from a long formula

    Yes i have everything typed in correct in code.

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Need to make a UDF from a long formula

    is it possible to upload an .xlsm file to look at?....

  7. #7
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Need to make a UDF from a long formula

    Also an example of the time code is:
    01:06:00:29

    Format is hh:mm:ss.00

  8. #8
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Need to make a UDF from a long formula

    Here it is
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-09-2013
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Need to make a UDF from a long formula

    have you figured out what I did wrong?

  10. #10
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Need to make a UDF from a long formula

    sorry it's taken so long to get back to you....I think I have figured out why the function doesn't work but I haven't figure how to fix it....when you take fEnd/fStart and multiply it by 86400*30 you get a data mismatch error. I believe it's because you are trying multiply a number times a string (TEXT)....there are a few functions out there but don't convert your format to something that works....you wold have to write a converter the string and makes it an actual excel time stamp....sorry I couldn't help....Maybe/probably somebody knows a better way.....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1