Match cell and paste in new sheet

twinpowr

Board Regular
Joined
Mar 14, 2007
Messages
73
Hi guys

I found this code on here, originally posted by AlphaFrog. im having a little difficulty using it for what i need.

i have filtered date on Filter_CSM, where dates are entered to the record in col H, there is a record number in col L.

I need to be able to find the cell with the dates, offset and use the record number in col l , copy the range a:l, find the corresponding record # in worksheet Data and paste over with the data from copied range in filter_CSM.

im not sure how to use the offset using the code below.

i hope that makes sense.

Here is the code:-

Code:
Sub MatchCopyPaste()
    
    Dim wsSource As Worksheet, wsDest As Worksheet
    Dim cell  As Range, Found As Range
        
    Set wsSource = Worksheets("Filter_CSM") ' Source
    Set wsDest = Worksheets("Data")   ' Destination
    
    Application.ScreenUpdating = False
    
    With wsDest
        ' Filter destination sheet column B for blanks
        .Columns("A:L").AutoFilter Field:=8, Criteria1:="<>"
        ' Loop through column I visible cells
        For Each cell In .Range("A2", .Range("l" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
            
            ' Look for match on Source worksheet
            Set Found = wsSource.Columns("L").Find(cell, , , xlWhole, xlByRows, xlNext, False)
            ' Copy\Paste if match found
            If Not Found Is Nothing Then
                cell.Offset(, 1).Resize(, 4).Value = Found.Offset(, 1).Resize(, 4).Value
            End If
        
        Next cell
        
        ' Clear autofilter
        .AutoFilterMode = False
    
    End With
    
    Application.ScreenUpdating = True
    
    MsgBox "Done.", vbInformation, "Copy Complete"

End Sub

Thank you in advance

Ally
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top