我正在尝试将值读入子函数,运行条件循环,然后在工作表中打印输出值。但是,我遇到了一些问题。在子函数 infiltPrint 中,我似乎无法获取要在单元格中打印的值。
Option Explicit
Dim dz() As Double
Dim WC() As Double
Dim fc() As Double
Dim NL, i As Integer
Dim sumdrain As Double
Dim infl As Double
Sub main()
Call InfiltRead
Call infilt
Call Infiltprint
End Sub
Sub InfiltRead()
Dim dz() As Double
Dim WC() As Double
Dim fc() As Double
Dim NL, i As Integer
Dim sumdrain As Double
sumdrain = 0
Dim infl As Double
'read inputs
NL = 10
infl = Cells(2, 1)
Application.ScreenUpdating = False
Worksheets("Sheet1").Activate
ReDim dz(NL)
ReDim WC(NL)
ReDim fc(NL)
For i = 1 To NL
dz(i) = Cells(1 + i, 3)
WC(i) = Cells(1 + i, 7)
fc(i) = Cells(1 + i, 5)
Next i
End Sub
Sub infilt()
Dim j As Integer
j = 1
While (infl > 0) And (j <= NL)
If infl > (fc(i) - WC(j)) * dz(j) Then
infl = infl - (fc(i) - WC(j)) * dz(j)
WC(j) = fc(i)
Else
WC(j) = WC(j) + infl / dz(j): infl = 0
End If
j = j + 1
Wend
If infl > 0 Then
sumdrain = sumdrain + infl
infl = 0
End If
End Sub
Sub Infiltprint()
Dim col As Double
Dim rw As Double
col = 7
For rw = 2 To 11
Cells(rw + 1, col).Value = WC()
Next rw
End Sub
我在“Cells(Row + 1, col) = WC()”行中不断收到类型不匹配
我知道这可能不是我的代码中唯一的错误。坦率地说,我不知道如何从渗透子打印我的值。我试图使用子主...