Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run Time Error for Vlookup & Match command


Hi Friends,

__1._ I use the following codes for vlookup

private sub combobox1_change()

TextBox1 = Application.WorksheetFunction.VLookup(CLng(ComboBo x1),
Sheet6.Range("a2:b65536"), 2)

it is working properly, But when we reached blank record by scrolling
through comboBox the run time error 13 saying type mismatch appears.
How can we overcome this problem?

_2._The same thing with match Command

Privat sub textbox1_afterupdate()

dim res as variant
res = Application.WorksheetFunction.Match(TextBox2,
Sheet6.Range("b2:b65536"), 0)

Textbox3 = Sheet6.Range("b1").Offset(res, -1).Value

it is also working properly, But when the record does not match then
run time error 1004 appears. I would like to display a message "Record
not Found" at this moment.

Thanks


Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=468870

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Run Time Error for Vlookup & Match command

Possibly use error handling

private sub combobox1_change()
On Error Resume Next
TextBox1 = Application.WorksheetFunction.VLookup(CLng(ComboBo x1),
Sheet6.Range("a2:b65536"), 2)
If Err.number < 0 then
msgbox "Record not found"
Err.clear
End if
On Error goto 0
End Sub

--
Regards,
Tom Ogilvy

"Syed Haider Ali"
wrote in
message news:Syed.Haider.Ali.1vm8if_1127149530.96@excelfor um-nospam.com...

Hi Friends,

__1._ I use the following codes for vlookup

private sub combobox1_change()

TextBox1 = Application.WorksheetFunction.VLookup(CLng(ComboBo x1),
Sheet6.Range("a2:b65536"), 2)

it is working properly, But when we reached blank record by scrolling
through comboBox the run time error 13 saying type mismatch appears.
How can we overcome this problem?

_2._The same thing with match Command

Privat sub textbox1_afterupdate()

dim res as variant
res = Application.WorksheetFunction.Match(TextBox2,
Sheet6.Range("b2:b65536"), 0)

Textbox3 = Sheet6.Range("b1").Offset(res, -1).Value

it is also working properly, But when the record does not match then
run time error 1004 appears. I would like to display a message "Record
not Found" at this moment.

Thanks


Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=468870



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
Worksheet function match - run time error Sajit Excel Worksheet Functions 3 July 8th 07 10:30 PM
VLOOKUP, INDEX & MATCH ERROR HELP sahafi Excel Worksheet Functions 6 September 12th 06 11:26 PM
First Time Error Using VLOOKUP malycom Excel Discussion (Misc queries) 4 February 17th 06 05:03 PM
Command Button run-time error Dominique Feteau Excel Programming 1 June 29th 04 02:57 AM
Run-time error on command button Phil Hageman[_3_] Excel Programming 4 November 4th 03 08:06 PM


All times are GMT +1. The time now is 07:02 PM.

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"