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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,203,127
Messages
6,053,667
Members
444,677
Latest member
LWilliamsAtchristies

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