我正在尝试复制、过滤D列= India and France和C列〉1/06/2020的值,并将这些唯一的过滤值粘贴到另一个工作表中,您能帮助我吗?
我尝试过,但无法创建多个筛选器并仅复制唯一值
Public Sub ConditionalRowCopy()
' Declare object variables
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim cell As Range
' Declare other variables
Dim sourceLastRow As Long
Dim targetLastRow As Long
' Set a reference to the sheets so you can access them later
Set sourceSheet = Workbooks("Bookcopy.xlsm").Worksheets("copy")
Set targetSheet = Workbooks("Bookpaste.xlsm").Worksheets("paste")
' Find last row in source sheet based on column "R"
sourceLastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "D").End(xlUp).Row
' Find cell with word "Emetteurs", search in column R)
For Each cell In sourceSheet.Range("D1:D" & sourceLastRow).Cells
' If match
If cell.Value = "India" Then
' Find last row in target sheet based on column "A"
targetLastRow = targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Row
' Copy entire row to next empty row in target sheet
cell.EntireRow.Copy Destination:=targetSheet.Range("A" & targetLastRow).Offset(RowOffset:=1)
End If
Next cell
End Sub
2条答案
按热度按时间dsekswqp1#
复制唯一值(2列)
vyswwuz22#
您可以使用内置
AutoFilter()
和RemoveDuplicates()
功能的Excel