+ Reply to Thread
Results 1 to 3 of 3

Target.Value - Must be a number

  1. #1
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256

    Target.Value - Must be a number

    Hi all,

    I'm using this and it works as expected, as long as you enter a number.
    However not all users are smart enough to follow those instructions, and
    they enter text which causes the code to run.

    What direction do i need to go so that text in A5 will not activate the code?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$5" And Target.Value > 20 Then
    MsgBox ("Test code 1")
    Else
    MsgBox ("Test code 2")
    End If
    End Sub
    Thx
    Dave
    "The game is afoot Watson"

  2. #2
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Modified as:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Isnumeric(Target.value) Then
    If Target.Address = "$A$5" And Target.Value > 20 Then
    MsgBox ("Test code 1")
    Else
    MsgBox ("Test code 2")
    End If
    End if
    End Sub
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

  3. #3
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by Myles
    Modified as:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Isnumeric(Target.value) Then
    If Target.Address = "$A$5" And Target.Value > 20 Then
    MsgBox ("Test code 1")
    Else
    MsgBox ("Test code 2")
    End If
    End if
    End Sub
    Hi Myles,

    Thank you. That works great. Now they won't mess it up.

    Thx again,

+ 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