+ Reply to Thread
Results 1 to 2 of 2

Display dates on userform

  1. #1
    Greg
    Guest

    Display dates on userform

    Hi I have been using the manual mode to try to work this out but I am stuck.

    How do I get a macro to work which will display on a userform upcoming
    events. Like a diary I have 3 columns

    which are

    A: column B: Column C: Column

    DATE TIME THE EVENT WHAT IS HAPPENING

    The userform is events1

    I would like this to only show the date 2 months in advance


    Any help would be appriciated

    Thanks in advance

    Greg




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

    VBA has a very flexible and easy to use function called DATESERIAL. Here this info on how to use it.

    _________________________________________________________________

    Returns a Variant (Date) for a specified year, month, and day.

    Syntax

    DateSerial(year, month, day)

    The DateSerial function syntax has these named arguments:

    Part Description
    year Required; Integer. Number between 100 and 9999, inclusive, or a numeric expression.
    month Required; Integer. Any numeric expression.
    day Required; Integer. Any numeric expression.

    Remarks

    To specify a date, such as December 31, 1991, the range of numbers for each DateSerial argument should be in the accepted range for the unit; that is, 1–31 for days and 1–12 for months. However, you can also specify relative dates for each argument using any numeric expression that represents some number of days, months, or years before or after a certain date.
    The following example uses numeric expressions instead of absolute date numbers. Here the DateSerial function returns a date that is the day before the first day (1 - 1), two months before August (8 - 2), 10 years before 1990 (1990 - 10); in other words, May 31, 1980.

    DateSerial(1990 - 10, 8 - 2, 1 - 1)

    For the year argument, values between 0 and 99, inclusive, are interpreted as the years 1900–1999. For all other year arguments, use a four-digit year (for example, 1800).

    When any argument exceeds the accepted range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 35 days, it is evaluated as one month and some number of days, depending on where in the year it is applied. If any single argument is outside the range -32,768 to 32,767, an error occurs. If the date specified by the three arguments falls outside the acceptable range of dates, an error occurs.
    _________________________________________________________________

    Hope this helps out,
    Leith Ross

+ 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