Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Macro for displaying a Message box based on a cell Text

Latest post Fri, Jul 18 2014 11:51 PM by Garys Student. 1 replies.
  • Mon, Dec 16 2013 7:41 AM

    • aneshdas
    • Top 150 Contributor
    • Joined on Fri, Dec 6 2013
    • Posts 8
    • Points 136

    Macro for displaying a Message box based on a cell Text

    Friends,

    Good day to everyone !

    I need a macro code for the following problem.

    I have an excel sheet and on that I am using drop down menu in Cell U8 to U357 (Data Validation). In this work sheet, If I selected the value "A" from the drop down menu, I want to Display a message box with a message " Please enter the absent mode" and once the user clicked OK on the message box automatically the selection should go to its parallel "V" cell. 

    Eg: As soon as I selected "A" from drop down menu in cell U10, the " Please enter the absent mode" message should appear with an OK button and after clicking the OK the cursor should select the "V10" Cell where the absent mode has to enter. I will be more happy if only the "V10" cell is active and the user can do anything in other cells Only after entering any value in the "V10" cell.

    Kindly help me with a macro for this and thanks in advance.

    • Post Points: 21
  • Fri, Jul 18 2014 11:51 PM In reply to

    • Garys Student
    • Top 150 Contributor
    • Joined on Mon, Aug 13 2012
    • Lakehurst, NJ, USA
    • Posts 8
    • Points 88

    Re: Macro for displaying a Message box based on a cell Text

    Enter the following event macro in the worksheet code area:

     

    Private Sub Worksheet_Change(ByVal Target As Range)

        Dim U As Range

        Set U = Range("U8:U357")

        If Intersect(Target, U) Is Nothing Then Exit Sub

        If Target.Value <> "A" Then Exit Sub

        MsgBox "Please enter the absent mode"

        Target.Offset(0, 1).Select

    End Sub

    Have a Great Day!

    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.