Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Vlookup Problem

You will get mismatch error if Vlookup does not find a match as it will then
return #N/A...

Use
If IsError(varDN) = True Then
MsgBox TextBox3.Value & " not found"
Else
MsgBox varDN
End If

In fact you do not need this message as you have already covered it in the
next IF statement...
"aftamath77" wrote:

I have a userform with textbox3. The user enters a value into textbox3.
When the user moves to the next userform control, I want VBA to check the
value entered in textbox3 against a table I have on a worksheet (CE Tables).
If the value exists in the table, the focus will move to the next control,
but if the value doesn't exist, I want a msgbox to give a warning, then clear
the value and return to textbox3. Currently, I get a "Type Mismatch" with
MsgBox varDN.Value.

Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)

Dim varDN As Variant

varDN = Application.VLookup(TextBox3.Value, Worksheets("CE
Tables").Range("O:O"), 1, False)
MsgBox varDN.Value

If IsError(varDN) = True And TextBox3.Value < "" Then
MsgBox "Non-Standard DN Value"
TextBox3.Value = ""
Textbox3.SetFocus
End If

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLOOKUP Problem, Please Help! Susan Excel Discussion (Misc queries) 2 September 4th 08 05:05 PM
VLOOKUP problem Ravenbear Excel Discussion (Misc queries) 3 July 24th 06 09:54 PM
Vlookup problem.. Neo1 Excel Worksheet Functions 5 March 16th 06 09:53 AM
vlookup problem shrutikhurana Excel Discussion (Misc queries) 2 February 9th 06 01:52 PM
Vlookup problem Big Jones Excel Worksheet Functions 0 August 18th 05 02:33 PM


All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"