Sync Code

T

Todd Huttenstine

Hey guys

I have 2 ranges. A:A and B:B. What is the code that will
go through range A:A and if it finds a value that is NOT
in range B:B, it will add it. If a value in range A:A is
found, then do nothing.


Todd
 
B

Bob Phillips

Hi Todd,

One way

Sub Sync()
Dim i As Long
Dim cLastB As Long
Dim oCell As Range

cLastB = Cells(Rows.Count, "B").End(xlUp).Row

On Error Resume Next
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
Set oCell = Columns(2).Find(Cells(i, "A").Value)
If oCell Is Nothing Then
cLastB = cLastB + 1
Cells(cLastB, "B").Value = Cells(i, "A").Value
End If
Set oCell = Nothing
Next i

On Error GoTo 0

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
F

Frank Kabel

Hi Todd
dou you need a VBA solution or would a worksheet formula also work for
you?. You may try
=SUMPRODUCT(--(COUNTIF(B1:B1000,A1:A1000)=0),A1:A1000)
 
Top