Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default validate # of decimal

I would like to validate cells to limit input to only 2 decimals. If the
user inputs a value with 2 decimals, I want to system to return an error
message.

Is there a way to do this without the use of VB?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,276
Default validate # of decimal

Hi try this solution given some time ago in the community

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.

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


"MauraC" wrote:

I would like to validate cells to limit input to only 2 decimals. If the
user inputs a value with 2 decimals, I want to system to return an error
message.

Is there a way to do this without the use of VB?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default validate # of decimal

MauraC wrote:
I would like to validate cells to limit input to only 2 decimals. If the
user inputs a value with 2 decimals, I want to system to return an error
message.

Is there a way to do this without the use of VB?



Data validation:

=A1*100=(INT(A1*100))
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default validate # of decimal

Data validation:
=NOT(MOD(100*A1,1))

Regards,
Bernd

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default validate # of decimal

Bernd P wrote:
Data validation:
=NOT(MOD(100*A1,1))

Regards,
Bernd


Yes!

Although as an afterthought, I would use this, which makes the number of decimal
places more obvious:


=NOT(MOD(10^2*A1,1))


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,059
Default validate # of decimal

"Bernd P" wrote:
Data validation:
=NOT(MOD(100*A1,1))


I believe that has a limit of 1342177.27.

Why not simply:

=TRUNC(A1,2)=A1

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,059
Default validate # of decimal

PS....

I wrote:
"Bernd P" wrote:
=NOT(MOD(100*A1,1))


I believe that has a limit of 1342177.27.


Perhaps I need to say "in Excel 2003". I don't know about Excel 2007. Then
again, the OP did not identify the Excel version she is working with.


----- original message -----

"JoeU2004" wrote in message
...
"Bernd P" wrote:
Data validation:
=NOT(MOD(100*A1,1))


I believe that has a limit of 1342177.27.

Why not simply:

=TRUNC(A1,2)=A1


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 automatic currancy decimal without entering the decimal? Giesej Excel Worksheet Functions 3 March 2nd 09 12:09 AM
Subtracting two 2-decimal place numbers gives result 13-decimal places? [email protected] Excel Worksheet Functions 5 March 12th 07 10:38 PM
Batch converting CSV files from comma-decimal to period-decimal Nodles Excel Discussion (Misc queries) 3 July 5th 06 06:57 PM
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Excel Discussion (Misc queries) 3 March 18th 06 06:20 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 05:45 PM.

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"