+ Reply to Thread
Results 1 to 2 of 2

limit textbox data to number range with IF statement

  1. #1
    Registered User
    Join Date
    10-17-2008
    Location
    Kinston, NC
    Posts
    20

    Talking limit textbox data to number range with IF statement

    Figured it out!

    Since the data entered is in a form and I am adding the data from the form to a spreadsheet, I simply had the "ADD button perform a few checks before adding the data. See my soultion below

    Private Sub cmdAdd_Click()

    'report error if no data entered
    ElseIf txtSide.Text = "" Then
    MsgBox "Must enter Side Panel Thickness!", vbOKOnly, "Error"
    ElseIf txtSide.Value < "0.92" Then
    MsgBox "STOP PRODUCTION!!! Side Panel measurement out of Spec Limits. Contact Supervisor.", vbOKOnly, "Error"
    ElseIf txtSide.Value > "1.08" Then
    MsgBox "STOP PRODUCTION!!! Side Panel measurement out of Spec Limits. Contact Supervisor.", vbOKOnly, "Error"


    'record into spreadsheet
    Application.ScreenUpdating = False
    Sheets("Data").Select
    Password = "1234"
    ActiveSheet.Unprotect Password
    Selection.AutoFilter Field:=1
    ActiveCell.SpecialCells(xlLastCell).Select
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = txtSide.Text
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select
    Password = "1234"
    ActiveSheet.Protect Password, True, True, True
    Sheets("Userform").Select
    ActiveWorkbook.Save
    End
    Application.ScreenUpdating = True
    End If
    End Sub
    Last edited by randyvann; 11-12-2008 at 03:54 PM. Reason: Title not descriptive enough

  2. #2
    Registered User
    Join Date
    10-17-2008
    Location
    Kinston, NC
    Posts
    20
    ISee above... Solved
    Last edited by randyvann; 11-12-2008 at 03:56 PM. Reason: Solved

+ 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