+ Reply to Thread
Results 1 to 6 of 6

Can Mod return a decimal?

  1. #1
    Registered User
    Join Date
    05-21-2007
    Posts
    79

    Can Mod return a decimal?

    I'm admittedly lacking in VBA savvy, so apologies if this is an easy fix, but is there any way to get the Mod operator to return a decimal result? For instance, I'd like this:

    Please Login or Register  to view this content.
    To assign ToChange to be 5 as of right now, in June. Is there a way to do this?

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92
    No the mod function cannot return a decimal.

    Mod only works with integers so any real numbers (those with deciamals) are rounded before performing the modulo function.

  3. #3
    Registered User
    Join Date
    05-21-2007
    Posts
    79
    Bummer. I suppose working around it manually won't be too rough, just nowhere near as elegant as a one-line solution.

    Thanks for the quick response, though, chergh!

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430
    What exactly are you trying to do?
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    05-21-2007
    Posts
    79
    Essentially, I'm trying to do what my bit of sample code implies. Here's the rundown:

    I have a worksheet with a range of dates in the format "yyyy.mm", but the dates themselvse are formatted as numbers, because that's how they're output by a SAS program. I want to have a macro look at the last of the dates, the most recent, and compare it to today's date, then tell me how many months separate the two dates.

    Right now, I see errors in my code's logic.

    Here's my new attempt:

    Please Login or Register  to view this content.
    I think that might work. I'm trying to hash out a problem with For Each ... Next loops right now.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430
    How about converting the information to a date?

    Please Login or Register  to view this content.

+ 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