+ Reply to Thread
Results 1 to 6 of 6

Using RoundDown function in a Macro

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Using RoundDown function in a Macro

    I have formula as follows that I am trying to use in a Macro. It is working fine as a function by itself.
    Please Login or Register  to view this content.
    I want to use the same formula within a macro. I tried a number of different ways to code, but can't get any of them to work. May latest attempt was as follows:
    Please Login or Register  to view this content.
    Thank you in advance for any assistance.
    Last edited by maacmaac; 07-27-2009 at 08:27 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Using RoundDown function in a Macro

    Not really clear what you're doing ... are you trying to return the complete years from date in E to current date ?

    Using your current approach perhaps:

    Please Login or Register  to view this content.
    Date being VBA equiv to Today()

    If you are always going to round down to nearest whole number you could alternatively just use Int rather than RoundDown.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Using RoundDown function in a Macro

    Your formula looks odd to me. Can you give me an example of the dates in column E and the desired result?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Using RoundDown function in a Macro

    I am trying to rounddown to the nearest whole number (or nearest whole year). Column E contains a date.

    So if the date in column E is 01/27/2011, and today's date is 7/27/2009, that is 549 days difference (~ 1 1/2 years). I need the forumla to return a value of 1 (rounds down to the nearest year).

    The rounddown formula did work perfect. I did try using the INT function in my Macro but could not get it working. Used following code:
    Please Login or Register  to view this content.
    I would be interested as to why I couldn't get the code working with the INT function.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Using RoundDown function in a Macro

    Like this then:
    Please Login or Register  to view this content.
    No, that's not right, try this:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-27-2009 at 08:04 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Using RoundDown function in a Macro

    Second code from JBeaucaire works perfect (as did the code from DonkeyOte). Thanks.

+ 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