+ Reply to Thread
Results 1 to 10 of 10

Message box on value

  1. #1
    Registered User
    Join Date
    10-03-2004
    Posts
    70

    Message box on value

    Hi all,

    I need to trigger a message box if 2 conditions are met: A1>1 and A2>1 Message "Limit Exceeded".

    On searching I've found some code but can't get it to work;

    Option Explicit

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Column > 1 Then Exit Sub
    If Target.Value > Target Then MsgBox _
    "Please complete commentary section", vbCritical, "Input required"
    End Sub
    But can't get it to work. What is the "Target.Column" Refering to please ?
    Last edited by OptionTrader; 11-29-2009 at 12:45 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Message box on value

    Give this a go

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-03-2004
    Posts
    70

    Re: Message box on value

    Thanks Dave, but doesn't work. Nothing happens when A1 and A2 exceed 1

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Message box on value

    Quote Originally Posted by OptionTrader View Post
    Thanks Dave, but doesn't work. Nothing happens when A1 and A2 exceed 1
    Sure it does, or I would not have replied.

    If it does not work in the worksheet_change then use the selection_change

    Are A1 and A2 Formulas?

  5. #5
    Registered User
    Join Date
    10-03-2004
    Posts
    70

    Re: Message box on value

    Quote Originally Posted by davesexcel View Post
    Sure it does, or I would not have replied.

    If it does not work in the worksheet_change then use the selection_change

    Are A1 and A2 Formulas?
    Tried the selection_change and still nothing happens. A1 and A2 are not formulas, but values typed in by the operator.

    I must be doing something very basic wrong, but what ?

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Message box on value

    Did you put the code in the worksheet module?

    Right click on the sheet tab and select view codes.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Post Re: Message box on value

    You also might need to reset application.EnableEvents = True

    In the VBE select Ctrl+G and then enter in the box provided application.EnableEvents = True and hit enter.

  8. #8
    Registered User
    Join Date
    10-03-2004
    Posts
    70

    Re: Message box on value

    Application.EnableEvents=True and still nothing

    See screen shot below...
    Attached Images Attached Images
    Last edited by OptionTrader; 11-29-2009 at 12:37 PM.

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Message box on value

    Quote Originally Posted by OptionTrader View Post
    Application.EnableEvents=True and still nothing

    See screen shot below...
    You did not place the code in the worksheet module.

    Right click on the sheet tab and select view codes, paste the code there.
    Last edited by davesexcel; 11-29-2009 at 12:49 PM.

  10. #10
    Registered User
    Join Date
    10-03-2004
    Posts
    70

    Re: Message box on value

    Many thanks.

+ 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