我有一列包含 .cpp 文件名列表,另一列表示测试用例。我想搜索工作表中与测试用例字符串匹配的所有行并从该行打印文件名。
column 1 column2
-------- ------------
file1.cpp testcase1
file2.cpp testcase1
file3.cpp testcase3
... .......
.... .......
所以最后我想要一个看起来像这样的输出:
Testcase1 Testcase2
file4.cpp file5.cpp
file9.cpp file8.cpp
file5.cpp file13.cpp
这是vba代码:
Function fileToTest(Search_string As String, _
Search_in_col As Range)
Dim result As String
Dim i As Long
Dim j As Long
Dim rArray(20) As String
Dim rCnt As Long
Dim rTmp As String
Dim found As Long
Dim testCases, Value As Variant
Dim currentRow As Long
Dim fCnt As Long
For i = 1 To Search_in_col.Count 'search each test case column
testCases = Split(Search_in_col.Cells(i, 1), ";")
For Each Value In testCases
If Search_string = Value Then
ActiveCell.Value = Search_in_col.Cells(i, 2).Value
' write the next row after active cell. not sure how to do this
End If
Next Value
Next i
End Function
当我尝试写入 ActiveCell.Value 时函数失败