I have used the find method to compare two columns (A and B)in different sheets. column A is the updated column while column B is the copied column.the code will loop through and columns and find for match cases. If there is a unique value in column A, it will copy it to column B. I have managed to code it but the unique value does not automatically appear in column B. Only when i click on the unique value cell of column A would it then be copied into column B.
Does anyone know why it cannot update automatically?
Code in column A:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = 9 Then
fabric = ActiveCell.Value
Module4.ChkFabric (fabric)
End If
End Sub</code>I have used a module to copy to column B:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">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</code>
Does anyone know why it cannot update automatically?
Code in column A:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = 9 Then
fabric = ActiveCell.Value
Module4.ChkFabric (fabric)
End If
End Sub</code>I have used a module to copy to column B:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">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</code>