View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
leonidas[_68_] leonidas[_68_] is offline
external usenet poster
 
Posts: 1
Default Find right cell (with duplicate values)


Hi,

I have a two worksheet, both used by another user. Worksheet(1) has
data in column B and column P. Worksheet(2) is a copy of worksheet(1)
(so differences can be tracked) and the user can add rows. So the range
of rows in worksheet(2) can be larger than in worksheet(1). The data in
both columns can have duplicates. For example:
W1 Column B: W1 Column P: W2 Column B: W2 Column P:
a 1 a 4
b 2 b 3
c 5 x 8
d 4 c 4
d 1 d 5
e 7 d 2
f 2 y 1
g 5 e 6
d 6 f 9
h 8 g 7
d 4
h 2
The values in column B can be text and numbers, the values in column P
are outcomes of formulas and are allways numbers.
I create a new sheet (as resume), copy the data from worksheet(2)
column B (is the most complete one) to the new sheet and then comes the
problem.
I now have to put the values in column P from worksheet(1) at the right
place behind the right values from column B in the resume-worksheet, but
there are duplicates. The code below doesn't work, because it allways
gets the first of the duplicates.
Can someone help me change this code so it does work? Thanks in
advance!


Code:
--------------------
Sub test()

For Each cell In Sheets("Begroting WVB Won").Range("B12:B242")
myvalue = cell.Offset(0, 14).Value
Set myCell = Worksheets("Totaaloverzicht Won") _
.Range("B:B").Find(cell.Value)
myCell(1, 3).Value = myvalue
Next cell

End Sub
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=568364