#VALUE! even though result returns a number

pizzaboy

Board Regular
Joined
Mar 23, 2015
Messages
56
Office Version
  1. 2019
Platform
  1. Windows
So I have a breakpoint set before the function returns the value. Everything seems fine, however the cell I'm passing to ("=GetStock_VolumeHighValue()") gives me "A value used in the formula is of the wrong datatype." error.

Am I missing something really obvious here?


Code:
Option Explicit


'%
    Enum StockVolume_HighLimit
        Opening = 50
        MidDay = 100
        BeforeClosing = 150
        
        AfterHours = 200
    End Enum



Public Function GetStock_VolumeHighValue() As StockVolume_HighLimit
    Dim result As StockVolume_HighLimit
    
    
    Select Case GetTrading_Session()
    
        Case TradingSession.Active
        
            result = StockVolume_HighLimit.BeforeClosing
            
            
        Case TradingSession.Early
        
            result = StockVolume_HighLimit.Opening
            
            
        Case TradingSession.Afternoon
        
            result = StockVolume_HighLimit.MidDay
            
            
        Case Else
        
            result = StockVolume_HighLimit.AfterHours
            
            
    End Select
    
    
    GetStock_VolumeHighValue = result
End Function

I've tried returning the value as an integer to no avail...

Any help would be really appreciated.

Cheers
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Seems like an error was being generated higher up the call queue.

This matter has now been resolved.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top