问题摘要:
每个“超级”和“子测试”的“通过”或“失败”列中的输入都是手动输入的,我想使用一个宏来使其自动化。它的作用就像一个AND
门,只有在其下的所有过程和子测试都通过的情况下,测试才通过。
如果存在“ F”,则表示该子测试失败,因此超级测试失败。如果存在“ NE”,则不执行该子测试,因此将不执行超级测试。 “ F”将压倒“ NE”,因此包含两者的测试将失败。
我尝试过的方法: 我虽然首先考虑了背景颜色和单元格样式,但这是确定需要填写哪一行的肯定方法。我不能将任何想法拼凑在一起。
为解决这个问题,我试图将其分解为两个宏,一个用于查找第一组空白并填写子测试空白,第二个用于填充其余的空白。第一个宏将找到一个空白空间,下面有一个空白空间。在这种情况下,每个需要填充的空白都在其下方有空间。找到空间后,它将循环运行,将所有单元格值添加到数组中,直到找到另一个空白为止。一旦找到,它将调用函数以在数组中查找特定的字符,然后将需要在已填写的单元格中找到的该字符放入需要填充的位置。理想情况下,您将运行此函数和一个类似的宏来找出Super -测试。
Sub Subtests()
Dim rng As Range, cel As Range
Dim TrackedCel As Range
Dim Subtests As Long
Dim arr() As Variant
Subtests = 0
For Each cel In rng
If IsEmpty(ActiveCell) = True And IsEmpty(ActiveCell.Offset(1, 0)) = False Then
Subtests = Subtests + 1
TrackedCel = cel
ActiveCell.Offset(1, 0).Select
Do Until IsEmpty(ActiveCell)
ReDim Preserve arr(1 To UBound(arr) + 1) As Variant
arr(UBound(arr)) = a.Value
Loop
'Call FIsInArray(valToBeFOund, arr) As Boolean'
If IsInArray = True Then
TrackedCel.Value = InputBox("F")
End If
Call NEIsInArray
If IsInArray = True Then
TrackedCel.Value = InputBox("NE")
End If
Call PIsInArray
If IsInArray = True Then
TrackedCel.Value = InputBox("P")
End If
End If
Next cel
End Sub
Function FIsInArray(valToBeFound As Variant, arr As Variant)
As Boolean
Dim F As Variant
For Each element In arr
If F = valToBeFound Then
IsInArray = True
Exit Function
End If
Next element
Exit Function
End Function
Function PIsInArray(valToBeFound As Variant, arr As Variant)
As Boolean
Dim P As Variant
For Each element In arr
If P = valToBeFound Then
IsInArray = True
Exit Function
End If
Next element
Exit Function
End Function
Function NEIsInArray(valToBeFound As Variant, arr As Variant)
As Boolean
Dim NE As Variant
For Each element In arr
If NE = valToBeFound Then
IsInArray = True
Exit Function
End If
Next element
Exit Function
End Function