+ Reply to Thread
Results 1 to 4 of 4

Need help with MsgBox..

  1. #1
    Registered User
    Join Date
    03-03-2005
    Posts
    23

    Need help with MsgBox..

    Hi, I need help in creating a message box that runs once a month on a specified date i.e. the last day of every month for example. Is it possible to do this..... thanks.

  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,258
    Hello Ahmed,

    Do you need the message box to appear when the workbook is first opened? When you say last day do you mean the last workday of the month or last day like the 30th or 31st?

    Thanks,
    Leith Ross

  3. #3
    Registered User
    Join Date
    03-03-2005
    Posts
    23
    Leith,
    yea when the workbook is opened on that day. The last working day of that month..

    thanks

  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,258
    Hello Ahmed,

    I apologize for the delay. Here is the code to run a message box on the last working day of the month when the workbook is opened. Put this code in the Workbook Open event.


    Private Sub Workbook_Open()

    Dim Today
    Dim YearNow
    Dim MonthNow
    Dim LastDay

    Today = Format(Now(), "mmm-dd-yyyy")
    YearNow = Format(Today, "yyyy")
    MonthNow = Format(Today, "mmm")

    Select Case MonthNow
    Case Is = "Jan", "Mar", "May", "Jul", "Aug", "Oct", "Dec"
    LastDay = Weekday(MonthNow & "-31-" & YearNow)
    If LastDay = 7 Then LastDay = MonthNow & "-30-" & YearNow
    If LastDay = 1 Then LastDay = MonthNow & "-29-" & YearNow
    Case Is = "Feb"
    LastDay = Weekday(MonthNow &"-28-" & YearNow)
    If LastDay = 7 Then LastDay = MonthNow & "-27-" & YearNow
    If LastDay = 1 Then LastDay = MonthNow & "-26-" & YearNow
    Case Is = "Apr", "Jun", "Sep", "Nov"
    LastDay = Weekday(MonthNow & "-30-" & YearNow)
    If LastDay = 7 Then LastDay = MonthNow & "-29-" & YearNow
    If LastDay = 1 Then LastDay = MonthNow & "-28-" & YearNow
    End Select

    If Today = LastDay Then
    <Display your Message Box here>
    End If

    End Sub


    If you have any questions, contact via e-mail at [email protected].

    Sincerely,
    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