Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Stop error code from executing

I have a userform that contains a textbox. The user types in the name
of the person they are removing from the sheet and the VB code
searches for that name, deletes it and hides the row. I want to add
code that will display a msgbox ifthey type in a name wrong or one
that doesn't exist. However, even if there is no error it still runs
the msgbox. How do i tell vb to skip the msgbox if there is no
error. My code is below.

Private Sub btnRem_Click()
Sheets(2).Cells(1, 1).Activate
On Error GoTo b
Cells.Find(What:=txtName.Value, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.Value = ""
Sheets(Array("Payroll Info", "Store Schedule")).Select
Selection.EntireRow.Hidden = True
Sheets(1).Activate
Selection.EntireRow.Hidden = True
b: MsgBox "That associate does not exist. Please double check the
spelling as it appears on the schedule and try again", vbExclamation
txtName.Value = ""
Sheets(2).Activate

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Stop error code from executing

Hi

If you exit the sub before the error handling runs it should work.
i.e. add the line noted below.

Selection.EntireRow.Hidden = True

exit sub

b: MsgBox "That associate does not exist. Please double check
the

hope this helps

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Stop error code from executing

That did the trick. Thanks a bunch.


On Mar 5, 11:42 am, "Incidental" wrote:
Hi

If you exit the sub before the error handling runs it should work.
i.e. add the line noted below.

Selection.EntireRow.Hidden = True

exit sub

b: MsgBox "That associate does not exist. Please double check
the

hope this helps



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
How can I stop a formula from executing based on a cell value? Ricke New Users to Excel 4 October 5th 08 09:39 PM
How to Stop VBA from executing hon123456 Excel Programming 6 November 23rd 06 05:23 PM
Code seems to stop, but no error messages show up BEEJAY Excel Programming 2 October 20th 06 01:31 PM
Excel Macro Stop Executing Agustus Excel Programming 0 March 27th 06 05:11 PM
do anybody have a sample code for executing excel macro from vb code?<eom B Deepak Excel Programming 2 September 30th 05 09:59 AM


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