简体   繁体   English

我需要帮助修复这个 VBA 宏

[英]I need help fixing this VBA macro

I am new In VBA. I dont know how to use it but I am trying.我是 VBA 的新人。我不知道如何使用它,但我正在尝试。 I am trying to create a code that say:我正在尝试创建一个代码来说明:

if tmin < t < tmax then put "Valid" in the cell of the comment column but if not then put "Invalid" only如果 tmin < t < tmax 则在注释栏的单元格中输入“有效”,但如果不是则仅输入“无效”

if it is valid then check if the argument < 0.001 if it is then put "Valid & LN" in cell如果有效则检查参数是否 < 0.001 然后将“Valid & LN”放入单元格

if the argument > 0.001 just put "Valid" only如果参数 > 0.001 只放“有效”

if the argument > 10 put "Valid & 0"如果参数 > 10 放“有效 & 0”

Here is my try out that doesn't work这是我的尝试,但不起作用

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

Here is how it has to look like and the columns I am using:这是它的外观以及我正在使用的列:

Tmax & Tmin cells Tmax 和 Tmin 细胞

在此处输入图像描述

Time, Argument and how the Comment cells have to look like时间、参数以及评论单元格的外观

在此处输入图像描述

My guess is我的猜测是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM