Thread: formula help
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default formula help

On Tue, 31 Mar 2009 13:34:04 -0700, Silverline
wrote:

what formula is used when you enter a number into cell and it is round up to
a multiple of 3. So if 20 is entered in a cell that it is changes it to 21.


You can't do what you describe using a formula.

You would have to use an event triggered macro.

To enter this event-triggered Macro, right click on the sheet tab.
Select "View Code" from the right-click drop-down menu.
Then paste the code below into the window that opens.

Be sure to set AOI to the range where you want this to occur.

======================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim AOI As Range, c As Range
Set AOI = Range("A:A")
If Not Intersect(Target, AOI) Is Nothing Then
Application.EnableEvents = False
For Each c In Intersect(Target, AOI)
If IsNumeric(c.Value) And Len(c.Value) 0 Then
c.Value = Application.WorksheetFunction.Ceiling _
(c.Value, 3)
End If
Next c
Application.EnableEvents = True
End If
End Sub
============================
--ron