Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Fixed decimal places in Excel

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
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.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default Fixed decimal places in Excel

This might help get you started.

Go to Data then validation then custom.

Then put in the Fixed( , ) formula. The first space is the number in
question which can be a cell reference and the next number is the number of
digits you want a number rounded to. This will round to your number of
digits instead of reject numbers with excess decimals. It may be beneficial
in that the one entering data will not have to round the number since it is
done for them.

This same formula can also be used in a cell without the data validation
part if that helps any.

"Garben" wrote:

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.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Fixed decimal places in Excel

Thanks - this is what I needed! I just need to change it to reference a
column instead of the whole worksheet.

"Bernie Deitrick" wrote:

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.




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Fixed decimal places in Excel

Use

If Target.Column < 1 Then Exit Sub

to control the column it works on: 1 for A, 2 for B, etc.

HTH,
Bernie
MS Excel MVP

"Garben" wrote in message
...
Thanks - this is what I needed! I just need to change it to reference a
column instead of the whole worksheet.

"Bernie Deitrick" wrote:

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.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set fixed Decimal places with no rounding azza Excel Worksheet Functions 4 July 4th 08 04:48 AM
Data validation with a fixed amount of decimal places [email protected] Excel Worksheet Functions 17 August 9th 07 12:44 PM
Want Fixed Decimal places in only 1 column MikeElectricUtility Excel Discussion (Misc queries) 4 July 12th 06 09:11 PM
tools|options|Edit tab|fixed decimal places Jonathan Cooper Excel Discussion (Misc queries) 1 September 29th 05 02:36 PM
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. SUKYKITTY Excel Discussion (Misc queries) 3 July 6th 05 01:50 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"