PDA

View Full Version : Solved: validation techniques



bopo
01-13-2007, 06:55 PM
:hi:

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.

mdmackillop
01-14-2007, 03:27 AM
I assume you're talking about a VBA function. Can you post it?

bopo
01-14-2007, 04:01 AM
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

Bob Phillips
01-14-2007, 04:35 AM
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