J
JC
I am trying to create a macro that will check a column in
one spreadsheet against a column in another. Everything
works fine but when it finds a match it copies the data I
want twice. I am using two FOR EACH statements and I
think that's where my problem is located. Here is some
of my code:
For Each x In CheckCell
For Each y In CompareRange
If x = y Then GoTo Paste Else GoTo Repeat
Paste:
xxx There are some loops here that copy cells from one
spreadsheet to another xxx
Repeat:
Next y
Next x
CheckCell is col C on spreadsheet 1 and CompareRange is
col B on spreadsheet 2. So I'm trying to find cells that
match in both ranges and when I find that match copy
certain cells in that row to spreadsheet 2. Again, it
does this, but it copies everything twice.
CloseDate WO# Description Notes Charge
1/29/2003 11094 Had initial Meeting 2
1/29/2003 11094 Had initial Meeting 2
2/13/2003 11094 Worked on the IP Scheme 1
2/13/2003 11094 Worked on the IP scheme 1
I'd like to fix the duplicates problem without having to
write another macro that deletes every other line.
Thanks for any help you can provide. This forum is
great!!
JC
one spreadsheet against a column in another. Everything
works fine but when it finds a match it copies the data I
want twice. I am using two FOR EACH statements and I
think that's where my problem is located. Here is some
of my code:
For Each x In CheckCell
For Each y In CompareRange
If x = y Then GoTo Paste Else GoTo Repeat
Paste:
xxx There are some loops here that copy cells from one
spreadsheet to another xxx
Repeat:
Next y
Next x
CheckCell is col C on spreadsheet 1 and CompareRange is
col B on spreadsheet 2. So I'm trying to find cells that
match in both ranges and when I find that match copy
certain cells in that row to spreadsheet 2. Again, it
does this, but it copies everything twice.
CloseDate WO# Description Notes Charge
1/29/2003 11094 Had initial Meeting 2
1/29/2003 11094 Had initial Meeting 2
2/13/2003 11094 Worked on the IP Scheme 1
2/13/2003 11094 Worked on the IP scheme 1
I'd like to fix the duplicates problem without having to
write another macro that deletes every other line.
Thanks for any help you can provide. This forum is
great!!
JC