View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Huge problem with comparing cells in different ranges and sheets


Sub copylikecells() 'from the destination sheet list in col E
For i = 2 To Cells(Rows.Count, "e").End(xlUp).Row
With Sheets("Sheet22").Columns(2)'modify to suit source
Set c = .Find(Cells(i, "e").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lc = Cells(i, Columns.Count).End(xlToLeft).Column + 1
c.Offset(, 1).Copy Cells(i, lc)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.