Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Ensuring input is rounded up to nearest 10

I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of 10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Ensuring input is rounded up to nearest 10

=CEILING(A1,10)
--
David Biddulph

"RayC" wrote in message
...
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of
10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Ensuring input is rounded up to nearest 10

Thanks, but how do I apply it to the same cell to avoid a circular reference?
If the user tried to enter 33 I want that cell to show the 40.

--
Ray


"David Biddulph" wrote:

=CEILING(A1,10)
--
David Biddulph

"RayC" wrote in message
...
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of
10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 860
Default Ensuring input is rounded up to nearest 10

Hi Ray,

Bit of a compromise on what you are asking for, but you could
set Data Validation to custom with a formula like this,
=OR(A1=10,A1=20,A1=30,A1=40,A1=50)
and then set the error alert message to say
"Input must be in multiples of 10"

HTH
Martin



"RayC" wrote in message
...
Thanks, but how do I apply it to the same cell to avoid a circular
reference?
If the user tried to enter 33 I want that cell to show the 40.

--
Ray


"David Biddulph" wrote:

=CEILING(A1,10)
--
David Biddulph

"RayC" wrote in message
...
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples
of
10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 751
Default Ensuring input is rounded up to nearest 10

To ensure, in Data Validation, that the number is a multiple of 10: If
you are working with, say, cell A1, in DV choose Custom and this
formula:

=MOD(A1,10)=0

Now, to automatically round up the entered number to the nearest
multiple of 10 you need a VBA event procedu

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then ' Change A1 to suit
If Target.Value Mod 10 < 0 Then
ceil = Application.WorksheetFunction.Ceiling(Target.Value , 10)
msg = "You should enter a number in multiple of 10" & vbCrLf
msg = msg & "Automatically increasing your amount to " & ceil
MsgBox msg
Target.Value = ceil
End If
End If
End Sub

Right-click the sheet tab. Choose View Code... The VBA IDE comes up.
Paste the above code to the window, after changing $A$1 to whatever
cell contains the input.

Does this help?
Kostis Vezerides

On Nov 23, 11:51 am, RayC wrote:
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of 10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Ensuring input is rounded up to nearest 10

Thanks Kostis, the MOD part works great, I don't need the complex VBA bit for
my simple application. Very much appreciated.
--
Ray


"vezerid" wrote:

To ensure, in Data Validation, that the number is a multiple of 10: If
you are working with, say, cell A1, in DV choose Custom and this
formula:

=MOD(A1,10)=0

Now, to automatically round up the entered number to the nearest
multiple of 10 you need a VBA event procedu

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then ' Change A1 to suit
If Target.Value Mod 10 < 0 Then
ceil = Application.WorksheetFunction.Ceiling(Target.Value , 10)
msg = "You should enter a number in multiple of 10" & vbCrLf
msg = msg & "Automatically increasing your amount to " & ceil
MsgBox msg
Target.Value = ceil
End If
End If
End Sub

Right-click the sheet tab. Choose View Code... The VBA IDE comes up.
Paste the above code to the window, after changing $A$1 to whatever
cell contains the input.

Does this help?
Kostis Vezerides

On Nov 23, 11:51 am, RayC wrote:
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of 10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks

Ray



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 751
Default Ensuring input is rounded up to nearest 10

Ray,
thanks for the feedback.

Regards

On Nov 23, 9:14 pm, RayC wrote:
Thanks Kostis, the MOD part works great, I don't need the complex VBA bit for
my simple application. Very much appreciated.
--
Ray

"vezerid" wrote:
To ensure, in Data Validation, that the number is a multiple of 10: If
you are working with, say, cell A1, in DV choose Custom and this
formula:


=MOD(A1,10)=0


Now, to automatically round up the entered number to the nearest
multiple of 10 you need a VBA event procedu


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then ' Change A1 to suit
If Target.Value Mod 10 < 0 Then
ceil = Application.WorksheetFunction.Ceiling(Target.Value , 10)
msg = "You should enter a number in multiple of 10" & vbCrLf
msg = msg & "Automatically increasing your amount to " & ceil
MsgBox msg
Target.Value = ceil
End If
End If
End Sub


Right-click the sheet tab. Choose View Code... The VBA IDE comes up.
Paste the above code to the window, after changing $A$1 to whatever
cell contains the input.


Does this help?
Kostis Vezerides


On Nov 23, 11:51 am, RayC wrote:
I am creating a form for hiring cutlery for my local village hall (a
charity). I need to ensure that hirers only order cutlery in multiples of 10.
How can I validate their input so that if they enter eg 33 it is
automatically rounded up to 40?
Thanks


Ray


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 gets rounded up !!! Dr Alok Modi MD Excel Discussion (Misc queries) 22 December 16th 08 12:44 AM
Ensuring 3 cells do NOT match GIdunno Excel Discussion (Misc queries) 12 September 6th 07 09:36 PM
numbers being rounded intemporal New Users to Excel 1 January 4th 06 09:44 PM
how do i add rounded numbers? echase Excel Discussion (Misc queries) 4 November 12th 05 06:42 PM
Ensuring deleted data cannot be recovered Jell Excel Discussion (Misc queries) 3 July 3rd 05 03:11 PM


All times are GMT +1. The time now is 07:11 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"