簡體   English   中英

Excel計算后返回字符串時的#value

[英]Returning #value when for string after an Excel calculation

這個用戶定義的函數計算一些值; 據此,我需要在調用單元格中返回一個字符串。

該函數中的MsgBox測試有效,但是在單元格中,我僅獲得#value! 錯誤。

為什么?

Function WoodClassify(Length As Double, Girth As Double, Description As String) As Double
    Dim cubicMeter As Double
    Dim Classification As String


If Length > 250 Then
    MsgBox ("TG B(I)")
    Classification = "TG B(I)"
ElseIf Length > 100 Then
    Classification = "XXXXXXX"
Else
    Classification = "WWWWWWWW"
End If

WoodClassify = Classification

End Function

Function WoodClassify(...) as Double

分類是一個字符串,並且已將函數設置為返回雙精度型。 它無法將字符串隱式轉換為雙精度,因此會產生值錯誤。

如果您希望函數返回一個字符串,該字符串應顯示為: Function WoodClassify(...) as String

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM