遍历列中的所有单元格,如果找到匹配项,则复制并粘贴文本

Loop through all cells in a column and copy and paste text if match is found

我正在为一项简单的任务而苦苦挣扎。此代码当前有效:

With ActiveSheet
    Set criteriarange = Range("A1:A" & LShtRow)
        For Each criteriacell In criteriarange
            If Not criteriacell.Value Like "tag:*" Then
                criteriacell.ClearContents
            End If
        Next criteriacell
        For row = LShtRow To 1 Step -1
            With .Cells(row, "B")
                If IsError(Application.Match(.Value, ArrDataNames, 0)) Then .ClearContents
            End With
        Next row
End With

我需要遍历这些相同的单元格并查找我正在调用的内容 "exceptions."我将这些异常放在一个数组中。目前该数组只有一个例外,它是 "FM",如果它在第 "B" 行中找到 "FM",那么我想从第 "E" 行中复制文本,并且将其粘贴到第 "H" 列第 i 行。这是我一直在尝试的,但它说 "type mismatch." 我确信这是一些简单的语法,但我已经尝试了一些东西但无法弄清楚。这是我的代码:

Dim ArrExceptions As Variant
ArrExceptions = Array("FM")

With ActiveSheet
    Set criteriarange = Range("A1:A" & LShtRow)
        For Each criteriacell In criteriarange
            If Not criteriacell.Value Like "tag:*" Then
                criteriacell.ClearContents
            End If
        Next criteriacell
        For row = LShtRow To 1 Step -1
            With .Cells(row, "B")
                If IsError(Application.Match(.Value, ArrDataNames, 0)) Then .ClearContents
            End With
        Next row
'New Code'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        For row = LShtRow To 1 Step -1
                If Application.Match(.Cells(row, "B").Value, ArrExceptions, 0) Then .Range(.Cells(row, "E")).Copy .Range(.Cells(row, "H"))
        Next row
End With
With ActiveSheet
    Set criteriarange = Range("A1:A" & LShtRow)
        For Each criteriacell In criteriarange
            If Not criteriacell.Value Like "tag:*" Then
                criteriacell.ClearContents
            End If
        Next criteriacell
        For row = LShtRow To 1 Step -1
            With .Cells(row, "B")
                If IsError(Application.Match(.Value, ArrDataNames, 0)) Then .ClearContents
            End With
        Next row
        For row = LShtRow To 1 Step -1
                If Not IsError(Application.Match(.Cells(row, "B").Value, ArrExceptions, 0)) Then .Cells(row, "E").Copy .Cells(row, "H")
        Next row
End With