我想定义一个变量范围,即从B13到E13,它在单元格F13上进行计数。但它可能是从B13到H13并在I13上返回相应的行数,并重复例如直到第15行.nodeC(i)=" A,A,B"
**B** **C** **D** **E** **F**
**12** C|O 1 2 3 Count
**13** A 1 1 0
**14** B
**15** C
这是我写的代码:
Dim a As Integer
a = 0
Dim b As Integer
b = 0
operations = 1
i = 1
Do While a <= sh1.Range("D6").Value
Do While operations <= sh1.Range("D4").Value
If sh2.Cells(12 + a, 3 + b) = operations Then
If sh2.Cells(13 + a, 2) = arrayC(i) Then
sh2.Cells(13 + a, 3 + b).Value = 1
Else
sh2.Cells(13 + a, 3 + b).Value = 0
End If
Else
operations = operations + 1
i = i + 1
End If
operations = operations + 1
i = i + 1
b = b + 1
Loop
If operations = sh1.Range("D4").Value Then
If sh2.Cells(12, 3 + b).Value = "Count") Then
Dim eachContaminant As String
eachContaminant = "C" & a " Column.count & a
Dim countRange As Range
countRange = sh2.Range(eachContaminant)
Dim count As Integer
count = Application.WorksheetFunction.Sum(countRange)
a = a + 1
b = 0
i = 0
End If
End If
Loop
如果有人可以帮忙请。