+ Reply to Thread
Results 1 to 6 of 6

MOD function in VBA

  1. #1
    Registered User
    Join Date
    02-01-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    4

    MOD function in VBA

    Hi,

    In the excel worksheet, I use MOD(YEAR();4) to determine whether there are 365 or 366 days in that year.

    I would like to use this function also in my User Defined Function VBA Code.

    I cannot find how to do this.

    Thanks in advance for your tips.

    Kind regards,

    Dirk.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: MOD function in VBA

    Hi,

    The VBA Mod functions takes the form

    12 MOD 5

    (which results in the value 2)

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: MOD function in VBA

    Here's a way:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: MOD function in VBA

    Hello Dirk_Diggler,

    Excel will incorrectly identify the year 1900 as a leap year. If you plan to test years for being leap years then you can use this formula for Georgian years starting with 1600 and onward.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: MOD function in VBA

    VBA does it correctly, Leith.

  6. #6
    Registered User
    Join Date
    02-01-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: MOD function in VBA

    That worked out fine!

    thank you for your help.

    Kind Regards,

    Dirk.

+ 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