我在2个包含STRING值列的工作表(WS1和WS2)中有2列:A和B. 我想填写第三列" C"在第三个工作表(WS3)中有差异。
简单地说,我想用WS1中的项目名称填充WS3:C列:A但不在WS2中:B。
答案 0 :(得分:1)
You could actually do quite simply:
The formula in column C is
=IF(COUNTIF($B$1:$B$10,A1),"",A1)
Here is a VBA alternative:
Option Explicit
Sub DisplayUnique()
Dim output As Range, r As Range
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
Set output = ThisWorkbook.Worksheets("Sheet1").Range("C1")
For Each r In ThisWorkbook.Worksheets("Sheet1").Range("A1:A10")
If ThisWorkbook.Worksheets("Sheet1").Range("B1:B10").Find(r.Value, , , xlWhole) Is Nothing Then
If Not dict.exists(r.Value) Then dict.Add r.Value, r.Value
End If
Next r
output.Resize(dict.Count, 1).Value = Application.Transpose(dict.keys)
End Sub