Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VALUE Errors | Excel Discussion (Misc queries) | |||
Excel Throwing Circular Errors When No Errors Exist | Excel Worksheet Functions | |||
#Value! errors | New Users to Excel | |||
IIf and value-errors | Excel Discussion (Misc queries) | |||
Unresolved Errors in IF Statements - Errors do not show in results | Excel Worksheet Functions |