Out of touch with vba and so i am sure its a silly mistake somewhere. Would be really helpful if someone could point that out
Code:
Private Function generate() As Integer
Dim source_size As Long
Dim target_size As Long
Dim i As Long
Dim j As Long
Dim count As Long
Dim source1 As Range
Dim target1 As Range
Set source1 = Worksheets("Filter").Range(C4, C6498)
Set target1 = Worksheets("30").Range(A2, AP95787)
source_size = source1.Height
target_size = target1.Height
For i = 1 To source_size Step 1
For j = 1 To target_size Step 1
If Application.source1.Cells(i, 1).Value = target1.Cells(j, 5).Value Then
target1.Row(j).Select
'Selection.Copy
Worksheet("result").Range("A1").Rows("1:1").Insert Shift:=xlDown
End If
Next j
Next i
generate = 0
End Function
Range(d, C6498)is not valid in this way. You could use e.g.Range("A1:C3")orRange(Cells(...), Cells(...)). Maybe you wantedRange("C4:C6498")?