Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Spreadsheet validation

Is there a way to set column "D" on a sheet to only accept (or automatically
round) a value in 0.50 increments?

Examples:

25.5 < ok
100 < ok
18.50 < ok
0.5 < ok
25.25 < invalid
35.3 < invalid

How can I do this?

Thanks much in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Spreadsheet validation

Try this

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
With Target
If IsNumeric(.Value) Then
.Value = Round(.Value / 0.5, 0) * 0.5
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--

HTH

RP
(remove nothere from the email address if mailing direct)


"quartz" wrote in message
...
Is there a way to set column "D" on a sheet to only accept (or

automatically
round) a value in 0.50 increments?

Examples:

25.5 < ok
100 < ok
18.50 < ok
0.5 < ok
25.25 < invalid
35.3 < invalid

How can I do this?

Thanks much in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Spreadsheet validation


"quartz" wrote in message
...
Is there a way to set column "D" on a sheet to only accept (or

automatically
round) a value in 0.50 increments?

Examples:

25.5 < ok
100 < ok
18.50 < ok
0.5 < ok
25.25 < invalid
35.3 < invalid

How can I do this?

Thanks much in advance


I don't know how to do this on the entire column, but I can show you how to
do this for a sinle cell like D1
1) Select cell D1
2) Open Data|Validation
3) Select Settings and Custom
4) Enter this =IF(OR(0 = D1 - INT(D1), 0.5 = D1-INT(D1)), True, false)

Unfortunately, I have the Swedish version of Excel so my translations may
not be correct. This function will work with negative values as well.

/Fredrik


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
Data Validation On A Cells With Data From A Different Spreadsheet Nat Govender Excel Discussion (Misc queries) 6 December 9th 08 05:23 PM
Validation - removal of over an entire spreadsheet Roger[_3_] Excel Discussion (Misc queries) 2 July 26th 07 03:41 AM
Validation (Drop down list vs simple text length validation) Bob Phillips[_6_] Excel Programming 2 April 27th 04 07:47 PM
Validation (Drop down list vs simple text length validation) Jason Morin[_2_] Excel Programming 1 April 27th 04 04:56 PM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


All times are GMT +1. The time now is 02:55 AM.

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

About Us

"It's about Microsoft Excel"