【发布时间】:2018-07-20 18:41:31
【问题描述】:
我在调用布尔函数的过程中使用了 if 语句;但是,当我运行程序时,它总是输出消息,就好像函数是真的一样。
Public Function INR() As Boolean
If Avg < 1.5 & SD < 0.5 Then
INR = True
Else
INR = False
End If
End Function
Public Sub PatientINR()
Range("B2", Range("B1").End(xlDown)).Name = "Name"
Dim cell As Range, reply As String, i As Long, x As Variant, Avg As Long, SD As Long
reply = InputBox("Enter patient's name", "INR", "Madelyn Carberry")
i = 1
x = Range("Name").Cells(i)
Do Until x = reply
i = i + 1
x = Range("Name").Cells(i)
Loop
Avg = Range("Name").Cells(i, 17)
SD = Range("Name").Cells(i, 18)
Call INR
If INR = True Then
MsgBox reply & "'s INR record is satisfactory for the procedure"
End If
If INR = False Then
MsgBox reply & "'s INR record is not satisfactory for the procedure"
End If
End Sub
【问题讨论】:
-
函数中
Avg和SD是如何设置的。用户函数应该只处理局部变量和参数。
标签: vba excel function if-statement boolean