Find方法唯一值不会自动出现在列上

我用find方法来比较不同工作表中的两列(A和B)。 列A是更新的列,而列B是复制的列。代码将循环遍历和列并查找匹配情况。 如果在列A中有一个唯一的值,它将它复制到列B.我已经设法编码,但唯一的值不会自动出现在B列。只有当我点击列A的唯一值单元格然后被复制到B列。

有谁知道为什么它不能自动更新?

A栏代码:

Private Sub Worksheet_SelectionChange(ByVal target As Range) If target.Column = 9 Then fabric = ActiveCell.Value Module4.ChkFabric (fabric) End If End Sub 

我已经使用了一个模块来复制到列B:

 Sub ChkFabric(ByRef fabric As String) Dim Rng, TgtC, ResC As Range Dim PrePlan As Worksheet Set PrePlan = Worksheets("Pre Master Plan") With PrePlan Set ResC = .Range("A:A") endrow = .Cells(PrePlan.Rows.Count, "A").End(xlUp).Row End With With ResC Set Rng = .Find(what:=Trim(fabric), LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then Else PrePlan.Cells(endrow + 1, 1) = fabric End If End With End Sub 

我写了一段代码从一列中获取唯一值(不包括一个项目,如果它有重复的),并写入另一个

 Sub uniq() Dim cntOccur As Integer Dim rowCount As Integer Dim Checkcol As Integer, Targetcol As Integer Dim currentRowValue As String Dim currentRow As Integer, brow As Integer Checkcol = 1 'Denotes A column Targetcol = 2 'Denotes B column rowCount = Cells(Rows.Count, Checkcol).End(xlUp).Row brow = 0 For currentRow = 1 To rowCount currentRowValue = Cells(currentRow, Checkcol).Value ' Check the number of occurrence of each and every cell in column A cntOccur = Application.WorksheetFunction.CountIf(Range("A1:A" & rowCount), currentRowValue) If cntOccur = 1 Then brow = brow + 1 ' If it is unique and has no duplicates then write in to B Cells(brow, Targetcol).Value = currentRowValue End If Next End Sub