Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Is there any procedure to ignore the error message by VBA and turn it with my MsgBox

  Asked By: Rabiah    Date: Dec 15    Category: MS Office    Views: 819
  

My problem is when I make UserForm that contain, textboxes and a
command button. The simulation is simple. There is two textbox as lower
value and higher value that used to enter a number which linked to
many cells that contain many linked formula on sheets.Where one textbox
show the result of the simulation.

And I run the operation on range of lower value and higher value, with
procedure For-Next. And some error will occure, on the operation if I
enter the lower value too small, or the higher value to big.

Is there any procedure to ignore the error message by VBA and turn it
with my MsgBox. And when I click OK on my MsgBox, the value that I have
entered in textbox is cleared so the macro still run and I can reenter
the textbox with a new value.

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Alisha Johnson     Answered On: Dec 15

Have you tried
On Error GoTo ErrorHandler
?
(See examples in Excel's VBA help.)

 
Answer #2    Answered By: Varick Fischer     Answered On: Dec 15

What are the upper and lower limits?????????????

 
Answer #3    Answered By: Haboos Kauser     Answered On: Dec 15

You could use

On error  Resume Next

to stop the error traps and then check the returned error.

But why not do checks of the input information BEFORE you do the For? You
should always validate user input before you use it.

 
Answer #4    Answered By: Bama Cohen     Answered On: Dec 15

I have tried by using On error  Go, just to handle error and show
my MsgBox then turn  the value  inputed to default value. I will try on error
resume.

 
Answer #5    Answered By: Hadil Khan     Answered On: Dec 15

Please don't use On Error for this. Use If statements to check the values put
into the cells  and avoid the For loop if the values are bad.

 




Tagged: