+ Reply to Thread
Results 1 to 7 of 7

Convert Formula to Function | PercentBetweenDates

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Mexico
    MS-Off Ver
    MS Office 2016
    Posts
    95

    Question Convert Formula to Function | PercentBetweenDates

    Experts, I'm trying to convert this formula:

    =IFERROR((DATEDIF(A1,TODAY(),"d")+1)/(DATEDIF(A1,B1,"d")+1),"Not start") to a VBA Function. Do you know how this can be done and just write at excel =PercentBetweenDates(A1,B1)

    Here is the function header that i want to use, please let me know if its feasible and any of you knows how to do it.

    Please Login or Register  to view this content.
    Last edited by pacosalasv; 03-01-2022 at 10:07 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,376

    Re: Convert Formula to Function | PercentBetweenDates

    Try this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Mexico
    MS-Off Ver
    MS Office 2016
    Posts
    95

    Re: Convert Formula to Function | PercentBetweenDates

    Quote Originally Posted by TMS View Post
    Try this:

    Please Login or Register  to view this content.
    It works so good if i run the macro with a button or call inside an other. But its possible to Type as formula inside cells? Such as we type for example = sum (Cell1,Cell2)?

    I mean, i want to dynamically select the cells from formula. like =PercentBetweenDates(XXX,YYY) instead of pre-define insides the macro as A1, B1. (I'm not sure if its possible)

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,600

    Re: Convert Formula to Function | PercentBetweenDates

    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,376

    Re: Convert Formula to Function | PercentBetweenDates

    I think it would need to be this:

    Note: StartDate.Address and FinishDate.Address rather than just StartDate and FinishDate

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-06-2013
    Location
    Mexico
    MS-Off Ver
    MS Office 2016
    Posts
    95

    Re: Convert Formula to Function | PercentBetweenDates

    Quote Originally Posted by TMS View Post
    I think it would need to be this:

    Note: StartDate.Address and FinishDate.Address rather than just StartDate and FinishDate

    Please Login or Register  to view this content.
    Works exactly how I expected. Thanks a lot for support @TMS & @protonLeah

    Happy coding!

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,376

    Re: Convert Formula to Function | PercentBetweenDates

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Convert Excel Formula to Function
    By cjr7315 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2021, 10:19 PM
  2. Convert Excel Formula to Function
    By cjr7315 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-10-2021, 10:19 PM
  3. [SOLVED] Convert a worksheet formula to a function
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2018, 12:37 PM
  4. Convert long formula to function
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2017, 01:50 AM
  5. Help - Convert formula into function
    By sanju2323 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-19-2016, 10:48 PM
  6. convert formula to VBA Function
    By prasjohn in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2015, 03:36 AM
  7. [SOLVED] Convert or add If Function to a formula
    By JohnDear in forum Excel General
    Replies: 5
    Last Post: 12-01-2011, 02:45 PM

Tags for this Thread

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