#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Sync Code

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sync Code

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)

"Todd Huttenstine" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Sync Code

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)

--
Regards
Frank Kabel
Frankfurt, Germany


Todd Huttenstine wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sync Excel with Outlook Chris Excel Discussion (Misc queries) 0 April 30th 08 05:03 PM
Mobile sync in Vista Richard E. Howard Excel Discussion (Misc queries) 1 November 13th 07 02:43 PM
Sync Worksheets in Different Workbooks FP Novice Excel Worksheet Functions 1 May 9th 07 06:46 PM
Can I sync worksheets within a document? Brenda Excel Discussion (Misc queries) 1 February 8th 07 11:57 PM
ProgressBar Out of Sync RDallas Excel Programming 2 January 13th 04 04:25 PM


All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"