我有以下代码可以使用但我需要添加另一个标准。我需要添加的标准是 *Utilities
的通配符搜索。因此,如果列L的单词 utilities
,则在复制和粘贴中包含该行。如果没有,请不要复制和粘贴。
Sub CopyData()
Dim Cl As Range
Dim SrcWbk As Workbook
Dim SrcSht As Worksheet
Dim DestSht As Worksheet
Dim Rng As Range
Application.ScreenUpdating = False
Set SrcWbk = Workbooks.Open("Transactional Activity PD 10-2017 (Expense
Accounts).xlsb")
Set SrcSht = SrcWbk.Sheets("Activity")
Set DestSht = ThisWorkbook.Sheets("Transactions")
With CreateObject("scripting.dictionary")
For Each Cl In DestSht.Range("AE2", DestSht.Range("AE" &
Rows.Count).End(xlUp))
If Not .exists(Cl.Value) Then .Add Cl.Value, Nothing
Next Cl
For Each Cl In SrcSht.Range("AE2", SrcSht.Range("AE" &
Rows.Count).End(xlUp))
If Not .exists(Cl.Value) And Cl.Offset(, -29).Value = "PV" And
Cl.Offset(, -15) Like "*Utilities" Then
If Rng Is Nothing Then
Set Rng = Cl
Else
Set Rng = Union(Rng, Cl)
End If
End If
Next Cl
End With
Rng.EntireRow.Copy DestSht.Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
谢谢!
答案 0 :(得分:0)
以下添加的条件仅包括在与列AE上执行的测试相同的行的列L中找到“实用程序”的行。未经测试。
element.focus()