Easy Macro question

AussieRed

New Member
Joined
Jun 4, 2002
Messages
5
I have to write a macro that does a calculation on a number entered into an input box. I must prevent 3 errors from occuring:
NullEntry error
TextEntry error
Range error
If 3 errors occur I must produce a message box that lists them. For example:

NullEntry error = 1
TextEntry error = 2
Range error = 0

I have been able to do all this, except that my counts are wrong. Any suggestions?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi AussieRed,

Please can you post your code so we can see what you have done?

Also, what do you mean by your 'counts are wrong' ?
 
Upvote 0
Have you tried using Excel's InputBox Method instead of VBA's InputBox Function?

It includes a Type argument which specifies the return data type. Excel deals with any entry errors.

Example, to prompt for a number:

Code:
Answer = Application.InputBox(prompt:="Enter a number", Type:=1)
 
Upvote 0

Forum statistics

Threads
1,225,073
Messages
6,182,700
Members
453,132
Latest member
nsnodgrass73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top