Consulting

Results 1 to 9 of 9

Thread: Alert/Message Box

  1. #1

    Alert/Message Box

    Hi, wonder if somebody can help me setup alert/message box based on date...

    I have 17 sheets, each sheet is the same format... in H7 on each sheet, I have date, its date stamp when workscope is updates.

    If possible, if H7 is within last 7 date, initiated alert popup message to a user, once sheet is open. Just want to alert user that sheet is update and they need to look for update at the bottom of the sheet... I start with code below but it does really work the way I need to. Any suggestion and help would be greatly appreciated.

    Sub msgAlertWSupdate()
    With Sheets("Date")
      If .Range("H1").Value - Date < 7 Then
            MsgBox "This module have updated workscope, please see bottom of the page for update" & vbCrLf & "Update On:" & vbTab & .Range("K1").Value ")
        End If
    End With
    End Sub
    Regards,
    Izet

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    what about...

    Sub msgAlertWSupdate()
    Dim sht As Worksheet
    Dim vMsg
    For Each sht In Sheets
        sht.Activate
        With sht
            If DateDiff("d", .Range("H1").Value, Date) < 7 Then
                'MsgBox "This module have updated workscope, please see bottom of the page for update" & vbCrLf & "Update On:" & vbTab & .Range("K1").Value
                vMsg = vMsg & sht.Name & vbCrLf
            End If
        End With
    Next
    If vMsg <> "" Then MsgBox vMsg, , "These modules have updated workscope"
    Set sht = Nothing
    End Sub

  3. #3
    Hi Ranman,

    Thanks for feedback and updated code, however when I run code it get stock on "if Datediff(" line. Also, what does "d" represent on that line.... column, date??? Type Mismatched, 13 error when running code.

    Regards,
    Izet
    Last edited by izet99; 09-26-2014 at 02:50 PM.

  4. #4
    Hi Ranman,

    Not sure but is it possible that I'm getting these error due to the fact that I have another few sheets that H7 cell type is not date...

    Would it be possible to add, array of sheet names for code to loop through, if sheet is visible, check for date, if less than 7 day old, alert message would popup... this way I would assign specific sheet to look for only. For example, Sheets, (CFF, CRF, ENG, LPTR...etc) 17 in total...

    Regards,
    Izet

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    Quote Originally Posted by izet99 View Post
    I have 17 sheets, each sheet is the same format... in H7 on each sheet, I have date, its date stamp when workscope is updates.
    but now you say

    Not sure but is it possible that I'm getting these error due to the fact that I have another few sheets that H7 cell type is not date...


    You need to be sure about what you are asking for.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Hi Aussiebear,

    My apologies, you're right... did not initially mention other 3 sheet that I'm using as database to populate those 17 sheets based on multiple condition. I guess I did not realized that those sheets might cause the issue, I'm sorry about that...

    Regards,
    Izet

  7. #7
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,873
    try putting the following in the ThisWorkbook code-module:
    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    For Each sht In Sheets(Array("CFF", "CRF", "ENG", "HPTR")) 'add other sheetnames here.
      If Sh Is sht Then
        If DateDiff("d", Sh.Range("H7").Value, Date) < 7 Then 'adjust the 7 to something else for threshold.
          MsgBox "look for update at the bottom of the sheet…"
        End If
      End If
    Next sht
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  8. #8
    Hi p45cal,

    Code worked perfectly, just as I intended, thank you very much. Also, thank you to all other guys for your support and inputs on this case.

    How Solved is assigned to the case?

    Regards,
    Izet

  9. #9
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    Go to the Thread tools dropdown just above the initial post and select it from there
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •