我想有条件地计算行数,一对列的一个条件。我写了一个循环,现在运行3列,(从j = 3到5)。我想做同样的循环但是对于200列的工作表。如果我会这样写"对于j = 3到200步骤3"我将计算工作表中所有列的数量,而我需要计数并为每对列分别生成结果。看来我需要一个阵列,但我不知道如何写它。
dpi > 300
答案 0 :(得分:0)
代码的逻辑当然需要澄清
可能它会帮助你:
(但检查两次和三次)
Function RabigatorCount_Ori_15()
Dim zelle As Range
Dim i As Integer
Dim Rabigator() As Integer
Dim posMonitoring As Integer
Dim j As Integer
Dim intLastRow As Integer
Dim intCounter(3) As Integer
Dim k As Integer
Dim counter As Integer
Set zelle = Cells.Find("is_monitoring_relevant")
posMonitoring = zelle.Column
Dim bPosMon As Boolean
Dim lVal_1&, lSgnVal_1&
Dim lVal_2&, lSgnVal_2&, bVal_2 As Boolean
Dim lCntIdx&
For j = 3 To 5
For i = 2 To 59
bPosMon = Cells(i, posMonitoring).Value = "c"
Select Case bPosMon
Case True
lVal_1 = Cells(i, j + 1).Value
lVal_2 = Cells(i, j + 2).Value
lSgnVal_1 = Sgn(lVal_1)
Select Case lSgnVal_1
Case 1
bVal_2 = (lVal_2 > 0)
Case Else ' 0, -1
bVal_2 = (lVal_2 < 0)
End Select
Select Case bVal_2
Case True
lCntIdx = lSgnVal_1 + 2
intCounter(lCntIdx) = intCounter(lCntIdx) + 1
Case False
' do somthing else
End Select
Case False
' do somthing else
End Select
Next ' i
Next ' j
RabigatorCount = intCounter
End Function