ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   user-function not returning any result (newbye) (https://www.excelbanter.com/excel-programming/339561-user-function-not-returning-any-result-newbye.html)

Frisk

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

Chip Pearson

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




Tushar Mehta

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



All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com