Functions in Excel macro

S

Srikanth Ganesan

Hello,

I am trying to write an Excel macro. I want to use the following
functions that are available in Excel. Please let me know what are the
corresponding VB functions/syntax for the macro:
Excel Functions:
MOD(n,k)
Floor(n,k)
Ceiling(n,k)

Thanks

Srikanth
 
N

Norman Jones

Hi Srikanth

You can use the Floor and Ceiling worksheet functions in VBA thus:

Res = Application.WorksheetFunction.Floor(n, k)
Res = Application.WorksheetFunction.Ceiling(n, k)

VBA has its own Mod operator, the syntax being:

Res = n Mod k
 
J

Jim Cone

Srikanth,

x = n Mod k
x = WorksheetFunction.Floor(n, k)
x = WorksheetFunction.Ceiling(n, k)

Regards,
Jim Cone
San Francisco, CA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top