如果名称(存在于表 1 和表 2 中(匹配,则使用索引匹配将数据从表 2 复制到表 1。
我能数出在潜艇运行后匹配了多少?
法典:
Sub Find_the_value()
Dim i As Integer
i = 0
For Each Cl In ActiveSheet.Range("A1:A10")
If Cl.Value = 5 Then
i = i + 1
Exit For
End If
Next Cl
MsgBox i
End Sub
你有现有的代码吗?声明一个整数并在每次找到匹配项时递增它应该相对简单。
编辑:
Sub Find_the_value()
Dim i As Integer
Dim Cl As Range
i = 0
For Each Cl In ActiveSheet.Range("A1:A10")
If Cl.Value = 5 Then
i = i + 1
End If
Next Cl
MsgBox i
End Sub