# Excel macro: how to use floor function in macro code

#### georgemathew46

##### New Member
Hi,

i am trying to get a floor value in excel macro.

eg:
assume x=20
(x/9)=2.222
but i want to print as 3 which can be accomplished using floor function.
but am not able to use excel inbuilt functions in macro.

### Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

#### Michael M

##### Well-known Member
x/9 will give 2.222, but the Floor function will give you 2 not 3.
To get 3 you will need the Ceiling function
Code:
``````Sub MM1()
Dim x As Integer
x = 20
ans = Application.Floor(x / 9, 1)
MsgBox ans
End Sub

Sub MM2()
Dim x As Integer
x = 20
ans = Application.Ceiling(x / 9, 1)
MsgBox ans
End Sub``````

#### georgemathew46

##### New Member
Thanks .... Works like a Charm..

Replies
3
Views
40
Replies
11
Views
137
Replies
6
Views
64
Replies
3
Views
53
Replies
2
Views
23