这是场景。两个电子表格,都包含名字,姓氏和姓名栏。
我只想列出两个电子表格中的名称。
如何?
谢谢!
答案 0 :(得分:0)
请记住,我们有3个工作表,Sheet1,Sheet2和Sheet3
根据需要进行修改,然后尝试:
Option Explicit
Sub test()
Dim ws As Worksheet, wsResults As Worksheet
Dim Lastrow As Long
With ThisWorkbook
'Set Sheet3 as wsResults
Set wsResults = .Worksheets("Sheet3")
'Clear wsResults
wsResults.UsedRange.Clear
'Loop all ws
For Each ws In .Worksheets
'If ws name <> Sheet3
If ws.Name <> "Sheet3" Then
'Find the last row of wsResults
Lastrow = wsResults.Cells(wsResults.Rows.Count, "A").End(xlUp).Row
'Copy ws used range after wsResults last row
ws.UsedRange.Copy wsResults.Range("A" & Lastrow + 1)
End If
Next ws
'Remove duplicates from wsResults based of first 3 columns
With wsResults
.UsedRange.RemoveDuplicates Columns:=Array(1, 2, 3), _
Header:=xlNo
End With
End With
End Sub