Rounding to nearest 2000

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

Is there a function similar to the "ceiling" function in Excel? I need
to compare a value and round it to the nearest 2000.

Cheers
Steph
 
Steph,

Paste the following code in any standard module:

Function F_ceiling(num1 As Double, num2 As Long) As Long
Dim num3 As Double
num3 = num1 Mod num2
F_ceiling = num1 - num3
If num3 > 0 Then F_ceiling = F_ceiling + num2
End Function

You can then call the function from code or use in query / form / report
design. The syntax is:
=F_ceiling(num1, num2)

where num1 is the value to be rounded up (can be a variable, control
reference, field reference etc.) and num2 is the significance (in your
example 2000, but can be any integer).

HTH,
Nikos
 
Thanks, it worked like a charm.

Steph

Nikos said:
Steph,

Paste the following code in any standard module:

Function F_ceiling(num1 As Double, num2 As Long) As Long
Dim num3 As Double
num3 = num1 Mod num2
F_ceiling = num1 - num3
If num3 > 0 Then F_ceiling = F_ceiling + num2
End Function

You can then call the function from code or use in query / form / report
design. The syntax is:
=F_ceiling(num1, num2)

where num1 is the value to be rounded up (can be a variable, control
reference, field reference etc.) and num2 is the significance (in your
example 2000, but can be any integer).

HTH,
Nikos
 
Back
Top