Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Creating Custom Function - A Little Help Please!
Have been trying to write my first custom function, to determine if a year is
a leap year, using the following formula provided by Microsoft: =IF(OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)< 0)),"Leap Year", "NOT a Leap Year") In my worksheet, for example, I plan to put the following formula in cell B1: =if(LeapYear(A1) = "leap",c209/t13,b23*U14). I cannot get the custom function (below) to work properly; it either comes back with an error, returns 0, or the wrong answer. So far, I've got: Public Function LeapYear(MyRange As Range) As Integer Dim ActiveCell As Range On Error GoTo LeapYearErr Application.Volatile LeapYear = "=IF(OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)< 0)),""leap"",""not"")" LeapYearErr: Exit Function End Function Can someone advise what I'm doing wrong here? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating custom charts | Charts and Charting in Excel | |||
Creating a Custom Excel Function to Calculate Gini Coefficients | Excel Worksheet Functions | |||
Creating an custom input box | Excel Worksheet Functions | |||
Creating a custom toolbar in VBA | Excel Programming | |||
Creating Custom Function: TRIMSTDEV | Excel Programming |