![]() |
User Defined Functions
I'm keen to learn how to write my own functions and would like to use
some microsoft functions as a starting point. So using =ceiling(number,multiple/digit) as an example can anyone supply the code that would be required to make this function if it didn't exist already in excel? Thanks Matty |
User Defined Functions
This is probably not a perfect implementation - but I hope it gives you some
ideas: Public Function MyCeiling(dblInputVal As Double, dblCeiling As Double) As Double Dim dbltemp As Double Dim lngtemp As Long Dim dblOutVal As Double lngtemp = Int((dblInputVal / dblCeiling)) dbltemp = (dblInputVal / dblCeiling) If lngtemp < dbltemp Or lngtemp = 0 Then dblOutVal = dblCeiling * (lngtemp + 1) Else dblOutVal = dblCeiling * lngtemp End If MyCeiling = dblOutVal End Function |
All times are GMT +1. The time now is 10:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com