LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating custom charts Taebaek Charts and Charting in Excel 1 November 27th 06 10:10 PM
Creating a Custom Excel Function to Calculate Gini Coefficients [email protected] Excel Worksheet Functions 3 February 21st 06 10:15 PM
Creating an custom input box [email protected] Excel Worksheet Functions 1 March 17th 05 03:45 AM
Creating a custom toolbar in VBA Gord Dibben Excel Programming 0 July 13th 04 06:04 PM
Creating Custom Function: TRIMSTDEV Norvin Laudon Excel Programming 1 October 23rd 03 08:36 PM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"