VBA to Copy data that meets requirements

sprigelz

Board Regular
Joined
Jan 7, 2016
Messages
98
Office Version
  1. 365
Platform
  1. Windows
Good day,

I need to special copy/paste (Values only) from a table in excel to a table on a tab that meet a special requirement.

Requirement; All rows in Table13, on sheet Call Center, that have the date 6/25/2019 on Column S (Pay Start) should be special copy/pasted (Values only) to Table134, on sheet eTechnologies

** The copy/paste should overwrite any data currently in that table **

Can this be done?
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try this

Change the date by which you need.

Code:
Sub Copy_data()
    Dim t1 As ListObject, t2 As ListObject
    
    Application.ScreenUpdating = False
    Set t1 = Sheets("Call Center").ListObjects("Table13")
    Set t2 = Sheets("eTechnologies").ListObjects("Table134")
    
    'Clear t2
    With t2.DataBodyRange
        If .Rows.Count > 1 Then
            .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Rows.Delete
        End If
        .Rows(1).ClearContents
    End With
    
    'Filter
    t1.Range.AutoFilter
    t1.Range.AutoFilter Field:=19, Criteria1:="[COLOR=#ff0000]6/25/2019[/COLOR]", Operator:=xlFilterValues
    
    'Copy and paste
    On Error Resume Next
    t1.DataBodyRange.SpecialCells(xlCellTypeVisible).Copy
    t2.DataBodyRange(1, 1).PasteSpecial xlPasteValues
    On Error GoTo 0
    
    t1.Range.AutoFilter
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Done"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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