Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default user-function not returning any result (newbye)

Hi all!
I'm writing a function with two arguments.
This function is part of a module for the worksheet.
I just can't make it work when inserting it into a spreadsheet cell.

Can you help?

Thanks.
Frisk.


Function Result(Value1 As Double, Value2 As Double) As Byte

Select Case Value2
Case Value2 < (20 / 100)
Result = 1
Case Value2 < (50 / 100)
Result = 2
Case Value2 < (100 / 100)
Result = 3
Case Value2 < (110 / 100)
Result = 4
Case Value2 < (120 / 100)
Result = 5

Case Else

Select Case value1
Case value1 < 20 / 100
Result = 1
Case value1 < 50 / 100
Result = 2
Case value1 < 100 / 100
Result = 3
Case value1 < 110 / 100
Result = 4
Case value1 < 120 / 100
Result = 5

Case Else
Result = 0

End Select

End Select

End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default user-function not returning any result (newbye)

Frisk,

'Result' is the name of an XL4 Macro function. Change the name of
the function to something else.



"Frisk" wrote in message
...
Hi all!
I'm writing a function with two arguments.
This function is part of a module for the worksheet.
I just can't make it work when inserting it into a spreadsheet
cell.

Can you help?

Thanks.
Frisk.


Function Result(Value1 As Double, Value2 As Double) As Byte

Select Case Value2
Case Value2 < (20 / 100)
Result = 1
Case Value2 < (50 / 100)
Result = 2
Case Value2 < (100 / 100)
Result = 3
Case Value2 < (110 / 100)
Result = 4
Case Value2 < (120 / 100)
Result = 5

Case Else

Select Case value1
Case value1 < 20 / 100
Result = 1
Case value1 < 50 / 100
Result = 2
Case value1 < 100 / 100
Result = 3
Case value1 < 110 / 100
Result = 4
Case value1 < 120 / 100
Result = 5

Case Else
Result = 0

End Select

End Select

End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default user-function not returning any result (newbye)

What does "I just can't make it work" mean?

I suspect you need to lose the variable name between each Case and the
less-than sign, i.e., you should have

Select Case Value2
Case Is < (20 / 100)
Rslt = 1
Case Is < (50 / 100)
Rslt = 2
Note that I replaced Result by Rslt just in case Result is a reserved
word at some level in VBA.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hi all!
I'm writing a function with two arguments.
This function is part of a module for the worksheet.
I just can't make it work when inserting it into a spreadsheet cell.

Can you help?

Thanks.
Frisk.


Function Result(Value1 As Double, Value2 As Double) As Byte

Select Case Value2
Case Value2 < (20 / 100)
Result = 1
Case Value2 < (50 / 100)
Result = 2
Case Value2 < (100 / 100)
Result = 3
Case Value2 < (110 / 100)
Result = 4
Case Value2 < (120 / 100)
Result = 5

Case Else

Select Case value1
Case value1 < 20 / 100
Result = 1
Case value1 < 50 / 100
Result = 2
Case value1 < 100 / 100
Result = 3
Case value1 < 110 / 100
Result = 4
Case value1 < 120 / 100
Result = 5

Case Else
Result = 0

End Select

End Select

End Function

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
User Defined Function returning #Value! DogLover Excel Worksheet Functions 4 November 25th 09 07:31 PM
Excel Average function not returning expected result gja63 Excel Worksheet Functions 3 August 28th 07 02:06 AM
Average function not returning expected result gja63 Excel Discussion (Misc queries) 4 August 28th 07 12:36 AM
IF function returning incorrect result Hillary E. Excel Worksheet Functions 2 August 22nd 06 05:43 PM
User function for returning several results briansol Excel Programming 2 June 24th 04 12:31 PM


All times are GMT +1. The time now is 12:43 PM.

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

About Us

"It's about Microsoft Excel"