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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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