View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Fixed decimal places in Excel

Garben,

Copy the code below, right-click the sheet tab, select "View Code" and paste
the code into the window that appears.
I have assumed that you want to do checking only on single cell entries.

HTH,
Bernie
MS excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
If Target.Value < Round(Target.Value, 2) Then
Target.Value = ""
MsgBox "Bad value. Bad, bad, value. Rejected!!!!"
End If
Application.EnableEvents = True
End Sub

"Garben" wrote in message
...
I am designing an Excel spreadsheet as a template for data entry. I would
like the cell to only allow two decimal places to be entered. For
example,
if a person entered 1.234, I would like the value to be rejected. For my
purposes, this would not be best accomplished through the fixed decimal
option as the user can still enter this value and have it accepted. I
have
Excel 2003.