Consulting

Results 1 to 2 of 2

Thread: Create an alert popup

  1. #1
    VBAX Regular
    Joined
    Nov 2011
    Posts
    23
    Location

    Question Create an alert popup

    Hello All,

    I am looking for a excel vba that would automatically provide an alert popup when data is pasted onto a sheet

    named "Orders" where the following 3 conditions are true...

    1. There is a specific phrase in column C Phrase is - 2) Replacement
    2. The same row where the phrase exists should have yesterday's date in column B
    3. The same row will have a blank cell in column F

    Thankyou in advance,

    Ike

  2. #2
    VBAX Newbie
    Joined
    Nov 2011
    Posts
    1
    Location

    This should get you started

    This may seem a little verbose, but it accounts for a lot of conditions you might not anticipate, like whether the user is pasting merged data, or if the "blank" cell is empty or has spaces, etc.

    [vba]
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells(1).Column = 3 Then TestForAlert Target.Cells(1)
    End Sub

    Private Sub TestForAlert(Target As Range)
    Dim MatchesPattern As Boolean

    MatchesPattern = False
    If Target.Value <> "2) Replacement" Then GoTo DONE
    If IsDate(Target.Offset(0, -1).Value) = False Then GoTo DONE
    If CLng(Target.Offset(0, -1).Value) <> CLng(Date) - 1 Then GoTo DONE
    If Trim(Target.Offset(0, 3).Value) <> "" Then GoTo DONE
    MatchesPattern = True

    DONE:
    If MatchesPattern Then
    MsgBox "User has pasted the matching patttern into " & Target.Address & "."
    End If
    End Sub
    [/vba]

Posting Permissions

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