+ Reply to Thread
Results 1 to 5 of 5

Thread: VBA to create a message box when a value is entered into a cell

  1. #1
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    London
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    863

    VBA to create a message box when a value is entered into a cell

    Dear all

    I am creating a complaints DB in Excel and would l like some VBA.

    Database Tab

    I would like that when the user enters a "Closure Date" col AA10:AA107, this automaticaly populates the "Status" col F10:F107 as closed. The Status col contains a DV List otherwise i'd use an if statment.

    If this is too tricky then i was thinking of -- if a date value is entered in cells AA10:AA107 then having a msg box with a reminder to change the status.

    I have found some code which i am trying to tinker with...

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rng As Range
       Set rng = Range("AA10:AA107")
       If Not Intersect(Target, rng) Is Nothing Then
           If rng = "HOW DO I PUT ANY VALUE HERE" Then
            MsgBox "Cell " & _
             rng.Address & " = PLEASE remember to change the complaint status to CLOSED"
           End If
       End If
    
       Set rng = Nothing
    
    End Sub
    Any help appreciated.
    Attached Files Attached Files
    Last edited by Blake 7; 02-13-2012 at 08:55 AM.
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  2. #2
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: VBA to create a message box when a value is entered into a cell

    Try:
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        Dim rng As Range
        Dim rCell As Range
        Set rng = Range("AA10:AA107")
        If Not Intersect(Target, rng) Is Nothing Then
            For Each rCell In Intersect(Target, rng).Cells
                If Len(rCell.Value) > 0 Then
                    MsgBox "Cell " & _
                           rCell.Address & " = PLEASE remember to change the complaint status to CLOSED"
                    ' OR USE
                    ' Application.enableevents = false
                    ' Cells(rcell.row, "F").Value = "Closed"
                    ' Application.enableevents = true
                End If
            Next rCell
        End If
    
        Set rng = Nothing
    
    End Sub
    Good luck.

  3. #3
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    London
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    863

    Re: VBA to create a message box when a value is entered into a cell

    Hi R - thanks v much for responding.

    I inserted the above code and voila, the msg box worked perfectly. Thanks

    Regarding

    ' OR USE
    ' Application.enableevents = false
    ' Cells(rcell.row, "F").Value = "Closed"
    ' Application.enableevents = true


    Please forgive me but could you explain further how to use this code?

    Thanks v much
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  4. #4
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: VBA to create a message box when a value is entered into a cell

    Just uncomment it and comment out your message box line. I just put it there to give you the option to autopopulate the Closed bit.
    Good luck.

  5. #5
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    London
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    863

    Re: VBA to create a message box when a value is entered into a cell

    many thanks. Perfect
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

+ 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.2.0