Consulting

Results 1 to 4 of 4

Thread: Solved: validation techniques

  1. #1

    Solved: validation techniques



    Basically I am using a vlookup function to pull info from a spreadsheet, however if I enter a value which doesnt exist, its goes mental and closes. Are they any simple methods to stop this happening, I have consiered a case statments, but though id get the experts opinions first, thanks.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I assume you're talking about a VBA function. Can you post it?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    No problem

     With txtcost1.Text
            txtdescription1.Text = Application.VLookup(.Text, Worksheets("Act Data").Range("A:C"), 2, False)
            txtcost1.Text = Application.VLookup(.Text, Worksheets("Act Data").Range("A:C"), 3, False)
            
        End With

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With txtcost1
    txtdescription1.Text = ""
    On Error Resume Next
    txtdescription1.Text = Application.VLookup(.Text, Worksheets("Act Data").Range("A:C"), 2, False)
    On Error GoTo 0
    If txtdescription.Text = "" Then
    MsgBox "Not found"
    Else
    txtcost1.Text = Application.VLookup(.Text, Worksheets("Act Data").Range("A:C"), 3, False)
    End If
    End With

    [/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •