Here is the code that I am trying. Its copying and pasting from one
worksheet to other but numbers are going into wrong place and its not
copy pasting that for all rows. So, during the debug, I found out that
res = error 2024 at certain value and thats where problem starts. I
checked my list and it has all numbers. Both lists are trimmed (trim
function). I compared both lists agains each other by doing two vlookup
and it return values ok. Anything else I can try or I might be missing
to diagnose the problem?
Sub copydata()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, rng1 As Range
Dim rng2 As Range, ii As Long, i As Long
Dim res As Variant
Set ws2 = Worksheets("All_PN")
Set ws1 = Worksheets("Family")
lastrow = ws2.Cells(Rows.Count, 1).End(xlUp).Row
Set rng1 = ws1.Range(ws1.Cells(2, 1), ws1.Cells(Rows.Count,
1).End(xlUp))
ii = lastrow
For i = lastrow To 2 Step -1
If ws2.Cells(i, 1) < ws2.Cells(i - 1, 1) Or i = 2 Then
If i = 2 Then i = 1
Set rng2 = ws2.Cells(i, 2).Resize(ii - i + 1, 1)
res = Application.Match(Cells(i, 1), rng1, 0)
If Not IsError(res) Then
rng2.Copy
rng1(res).Offset(0, 150).PasteSpecial xlValue,
Transpose:=True
End If
ii = i - 1
End If
Next
End Sub
--
sa02000
------------------------------------------------------------------------
sa02000's Profile:
http://www.excelforum.com/member.php...o&userid=27747
View this thread:
http://www.excelforum.com/showthread...hreadid=527623