Insist on 3 decimal places given

L33

Board Regular
Joined
Jul 2, 2008
Messages
108
Hi,

I am assisting with the creation of something where the user has to be made to enter a number with 3 decimal places, even if they're all zeros. We've got the custom format set up so as to display as 0.000, but obviously this just makes the user able to enter "12", it display as "12.000", at which point the user shrugs and moves on. We want to insist that they enter those three decimal places.

Is there any way of using data validation to create an input mask to do this? Or perhaps a simple piece of VBA that runs when that cell is changed - any pointers?

Or do we have to get into user form territory if we really want to do this? My colleagues not keen on that as this is literally the only field that we've got problems with, and it would mean re-designing the whole complex model he's done already.

thanks
L33
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I'm sure there must be a better way but if no-one else can think of one, this is the best idea I could come up with...

Set the cell to Text when it's empty and use the Worksheet_Change event to detect when someone types into it. Check what they've entered via the event handler and if it's okay, reformat the cell to Number with three decimal places, otherwise display a message box (if that's what you want to do) and clear the cell.

This requires macros to be enabled.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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