+ Reply to Thread
Results 1 to 2 of 2

need to check whehter value ented is within range in excel using vba code

Hybrid View

ssbhatban need to check whehter value... 10-30-2015, 01:10 AM
vichopalacios Re: need to check whehter... 11-04-2015, 05:48 PM
  1. #1
    Registered User
    Join Date
    10-29-2015
    Location
    banaglore
    MS-Off Ver
    2007
    Posts
    8

    need to check whehter value ented is within range in excel using vba code

    Dear Friends

    i am new to vba coding & don't have much experience. but i have created a spreadsheet where in i have already used some coding which is working fine

    i want to check whether the value etnered in a particular column is whole no & if it is whole no it should be within 0 - 200 only. if not it should give a error message . i had done it using data validation but now i have used it for some other thing & hence i want a vba code for it.

    i tried the following code it si not working 7 it als odoesn to check whether it is within 0 - 200.

    If Target.Column = 19 And Target.Row >1 And Target.Row <= 1001 And _
    Target.Value <> Int(Target.Value) Then
    Cells(Target.Row, Target.Column - 1).ClearContents
    MsgBox ("not an integer value")
    End If

    early reply is appreciated

    with regards

  2. #2
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: need to check whehter value ented is within range in excel using vba code

    @ ssbhatban



    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Target.Column = 19 And Target.Row > 1 And Target.Row <= 1001 Then
        If Target.Value <> Int(Target.Value) Then
            'With the next line you are deleting the cell to the left of target
            Cells(Target.Row, Target.Column - 1).ClearContents
            MsgBox ("not an integer value")
        End If
        
        If Target.Value < 0 Or Target.Value > 200 Then
            MsgBox ("not in the accepted range from 0 to 200")
        End If
    End If
    End Sub
    Barriers are there for those who don't want to dream

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Getting error 91 with code to check if range contains data
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2014, 01:56 AM
  2. Replies: 0
    Last Post: 02-23-2014, 10:31 PM
  3. code to check range, if value = N then add another cell to total
    By ds2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2011, 07:46 AM
  4. Help modifying code to check for text in a range prior to email sheet.
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-09-2009, 06:16 PM
  5. Macro to check range, if false check another range until true, then copy
    By jayers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2009, 04:19 PM
  6. how can i tell if i have ented the same numbers twice in a column
    By items entered twice in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-03-2006, 02:00 PM
  7. [SOLVED] how can i tell if i have ented the same numbers twice in a column
    By items entered twice in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-03-2006, 10:02 AM
  8. [SOLVED] VBA Code to check formulas in a range
    By FrigidDigit in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-16-2005, 12:05 PM

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