我必须实现这段代码,但我不确定语法,我有“结束一个If句子”的问题,第一次我在VB上写了一个宏。
请帮助您编写此代码。我需要把它的结果放在Cell CK6中:
(编辑代码)
Sub Funcion()
Dim listo As Boolean
Dim min As Integer
Dim max As Integer
Dim beta As Integer
Dim tolerancia As Long
Dim deficit As Long
listo = False
min = 0
max = 1
beta = 0
tolerancia = 0.000001
While listo = False
prom = (min + mas) / 2
deficit = Worksheets("ETR").Cells(6, "CI")
If (deficit > 0) Then
If (deficit < tolerancia) Then
beta = prom
listo = True
Else: min = prom
End If
Else
If (Abs(deficit) < tolerancia) Then
beta = prom
listo = True
Else: max = prom
End If
End If
Wend
End Sub
现在有什么问题吗?宏被卡住但至少没有显示错误。