Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Vlookup What if not Found

How do I make this code not error if the value in cboCarPartModel is
not found in my wo worksheet? It works fine if the value is found but
errors if not found. Jody

Private Sub cboCarPartModel_Change()
Dim wo As Range
Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s")
If Me.cboCarPartModel.Value "" Then
Label3.Caption = Application.VLookup(cboCarPartModel.Value, wo, 2,
False)
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Vlookup What if not Found

Hi SS,

One way:

Private Sub cboCarPartModel_Change()
Dim wo As Range
Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s")
If Me.cboCarPartModel.Value "" Then
On Error Resume Next
Label3.Caption = _
Application.VLookup(cboCarPartModel.Value, wo, 2, False)
If Err.Number < 0 Then MsgBox "Not found!"
On Error GoTo 0
End If
End Sub


---
Regards,
Norman



"ssjody" wrote in message
oups.com...
How do I make this code not error if the value in cboCarPartModel is
not found in my wo worksheet? It works fine if the value is found but
errors if not found. Jody

Private Sub cboCarPartModel_Change()
Dim wo As Range
Set wo = Worksheets("cpModels").Range("cpModelNameAndNumber s")
If Me.cboCarPartModel.Value "" Then
Label3.Caption = Application.VLookup(cboCarPartModel.Value, wo, 2,
False)
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Vlookup What if not Found

Thanks Norman! Works Great!

Reply
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 would begin one row below what the first one found? Leong David Excel Worksheet Functions 4 November 21st 09 02:02 PM
Formula have a VLOOKUP but want it to =0 if no value is found Nicole Excel Worksheet Functions 3 October 26th 09 05:20 AM
VLookup Value not found ? Jeff C Excel Discussion (Misc queries) 6 October 14th 07 11:56 PM
vlookup not found BadgerDave Excel Worksheet Functions 1 April 11th 06 03:29 PM
use Vlookup for sum all found value? Ivan Excel Programming 4 July 6th 04 02:22 AM


All times are GMT +1. The time now is 05:32 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"