+ Reply to Thread
Results 1 to 10 of 10

Message box on value

Hybrid View

  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,524

    Re: Message box on value

    Give this a go

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Range("A1") > 1 Then
    If Range("A2") > 1 Then
    MsgBox "Limit Exceeded."
    End If
    End If
    
    End Sub

  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,524

    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,524

    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
    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