#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Errors


Hello, I am not too familiar with errors in my code and was hoping for
some help with this please.

I have a control box linked to a stock spreadsheet. After I update this
box(Which is for the stock number), the label next to it will update
with the stock item description. My code does a vlookup for this
value:

Public Sub BinNumber1_AfterUpdate()
Description1 = (WorksheetFunction.VLookup(BinNumber1.Value,
Worksheets("Current Stock").Range("A:B"), 2, False))
End Sub

This works fine if a valid stock number is entered but if someone
enters a bogus number I would like my msgbox to appear saying "Bad
stock number blah blah.." instead of VB opening for debugging.

Thanks in advance for any help.

John


--
johncassell
------------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=391660

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Errors

I usually use code that does a countif, than if it eguals 0 I send a message
to the user.

If WorksheetFunction.Countif(Worksheets("Current Stock").Range("A:B"),
BinNumber1)= 0 then
Msgbox "Bin Number Invalid"
exit sub
Else
'''' your code here
End if

--
steveB

Remove "AYN" from email to respond
"johncassell"
wrote in message
...

Hello, I am not too familiar with errors in my code and was hoping for
some help with this please.

I have a control box linked to a stock spreadsheet. After I update this
box(Which is for the stock number), the label next to it will update
with the stock item description. My code does a vlookup for this
value:

Public Sub BinNumber1_AfterUpdate()
Description1 = (WorksheetFunction.VLookup(BinNumber1.Value,
Worksheets("Current Stock").Range("A:B"), 2, False))
End Sub

This works fine if a valid stock number is entered but if someone
enters a bogus number I would like my msgbox to appear saying "Bad
stock number blah blah.." instead of VB opening for debugging.

Thanks in advance for any help.

John


--
johncassell
------------------------------------------------------------------------
johncassell's Profile:
http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=391660



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Errors


I would never have thought of that in a million years, thanks a lot
steve.


--
johncassell
------------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=391660

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Errors

John,

You're very welcome!!!

Just another tid-bit I picked up from this ng...

--
steveB

Remove "AYN" from email to respond
"johncassell"
wrote in message
...

I would never have thought of that in a million years, thanks a lot
steve.


--
johncassell
------------------------------------------------------------------------
johncassell's Profile:
http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=391660



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
VALUE Errors nastech Excel Discussion (Misc queries) 1 October 10th 07 09:28 AM
Excel Throwing Circular Errors When No Errors Exist MDW Excel Worksheet Functions 1 August 10th 06 02:15 PM
#Value! errors Field8585 New Users to Excel 1 February 7th 06 09:25 PM
IIf and value-errors Ian Excel Discussion (Misc queries) 9 February 6th 06 01:13 PM
Unresolved Errors in IF Statements - Errors do not show in results Markthepain Excel Worksheet Functions 2 December 3rd 04 08:49 AM


All times are GMT +1. The time now is 08:24 PM.

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

About Us

"It's about Microsoft Excel"