#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default UDF's

I'm trying my hand in UDFs. In practice I created the following UDF in a
module

Function Area(Length As Double, Width As Double)
Area = Length * Width
End Function

Back in work book, I type =Area(A1,B1) in cell C1.

The result shown in the cell is 0. The result shown from the formula
dialogue box is 24. I have no idea what's going on. Any help is sppreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default UDF's

try (Length As Range, Width As Range)

On 24 Mar, 13:13, shane wrote:
I'm trying my hand in UDFs. *In practice I created the following UDF in a
module

Function Area(Length As Double, Width As Double)
* * *Area = Length * Width
End Function

Back in work book, I type *=Area(A1,B1) in cell C1. *

The result shown in the cell is 0. *The result shown from the formula
dialogue box is 24. *I have no idea what's going on. *Any help is sppreciated.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default UDF's

I used your exact code in a standard code module and it worked like a charm.
So just to verify...

Your code is exactly as posted. No spelling mistakes or such. Do you use
Option Explicit at the top of your code module?
--
HTH...

Jim Thomlinson


"shane" wrote:

I'm trying my hand in UDFs. In practice I created the following UDF in a
module

Function Area(Length As Double, Width As Double)
Area = Length * Width
End Function

Back in work book, I type =Area(A1,B1) in cell C1.

The result shown in the cell is 0. The result shown from the formula
dialogue box is 24. I have no idea what's going on. Any help is sppreciated.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default UDF's

What do you have in A1 and B1?

Perhaps the numbers are actually Text?

Format to General then re-enter the numbers in A1 and B1


Gord Dibben MS Excel MVP

On Wed, 24 Mar 2010 05:13:01 -0700, shane
wrote:

I'm trying my hand in UDFs. In practice I created the following UDF in a
module

Function Area(Length As Double, Width As Double)
Area = Length * Width
End Function

Back in work book, I type =Area(A1,B1) in cell C1.

The result shown in the cell is 0. The result shown from the formula
dialogue box is 24. I have no idea what's going on. Any help is sppreciated.


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default UDF's

Interestingly enough I tried that and text or number makes no difference. It
works in either case. I assume that it is becuse he declared the arguments as
double causing XL to do an implicit conversion. If I enter text such as abcd
the function returns #Value instead of 0.
--
HTH...

Jim Thomlinson


"Gord Dibben" wrote:

What do you have in A1 and B1?

Perhaps the numbers are actually Text?

Format to General then re-enter the numbers in A1 and B1


Gord Dibben MS Excel MVP

On Wed, 24 Mar 2010 05:13:01 -0700, shane
wrote:

I'm trying my hand in UDFs. In practice I created the following UDF in a
module

Function Area(Length As Double, Width As Double)
Area = Length * Width
End Function

Back in work book, I type =Area(A1,B1) in cell C1.

The result shown in the cell is 0. The result shown from the formula
dialogue box is 24. I have no idea what's going on. Any help is sppreciated.


.

Reply
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
UDF's via Automation Addin in Excel 2010? Ralf Steinstraesser Excel Worksheet Functions 1 February 15th 10 03:44 PM
UDF's & puzzling recalculation behavior Brian McCarthy Excel Worksheet Functions 3 July 31st 09 04:44 PM
UDF's in Excel '07 Jack Setting up and Configuration of Excel 0 November 12th 07 09:27 PM
UDF's using other UDF's millsy Excel Worksheet Functions 9 December 18th 05 08:38 PM


All times are GMT +1. The time now is 05:53 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"