我需要帮助修复此V​​BA宏

时间:2020-02-23 19:41:40

标签: excel vba

我是VBA中的新手。我不知道如何使用它,但我正在尝试。我正在尝试创建一个代码:

如果tmin 注释列的单元格中,如果不是,则仅将“无效”放置

如果有效,则检查参数<0.001 然后将“ Valid&LN”放入单元格

如果参数> 0.001,则仅输入“有效”

如果参数> 10,则输入“有效&0”

这是我的无效尝试

Option Explicit
Function VC(t As Double, argument As Double, tmax As Double, tmin As Double) As Double
Dim i As String
If tmin < t < tmax And argument < 0.001 Then
    i = "Valid & LN"
ElseIf argument > 10 Then
    i = "Valid & 0"
Else
    i = "invalid"
End If
End Function

这是它的外观以及我正在使用的列:

Tmax和Tmin细胞

enter image description here

时间,参数以及注释单元格的外观

enter image description here

1 个答案:

答案 0 :(得分:1)

我的猜测是

Option Explicit

Function VC(t As Double, argument As Double, tmax As Double, tmin As Double) As String

    Dim i As String

    If tmin < t And t < tmax Then

        i = "Valid"

        If argument < 0.001 Then
            i = "Valid & LN"
        ElseIf argument > 10 Then
            i = "Valid & 0"
        End If

    Else
        i = "invalid"

    End If

    VC = i

End Function
相关问题