Copy paste special

STIRRELL

Board Regular
Joined
Dec 30, 2010
Messages
62
Office Version
  1. 365
Hi,
I am using copy-paste the values from an autofilter onto another sheet. But for some reason, it is only copying and pasting the first row over and over. Please help.

Range("A1:Z5000").SpecialCells(xlCellTypeVisible).Copy
Worksheets("20").Range("A1:Z5000").PasteSpecial Paste:=xlPasteValues



thank you,
Sharon
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Good, the code works, it would be best if you upload the rest of the code, greetings
 
Upvote 0
Sorry- when I run the code the paste only copies the first row over and over again.

Sub FILTER_COPY_PASTE()
Worksheets("Certify").Select



With ActiveSheet.Range("A1")
.AutoFilter Field:=6, Criteria1:="20"
.AutoFilter Field:=25, Criteria1:="X"
End With

Range("A1:Z5000").SpecialCells(xlCellTypeVisible).Copy
Worksheets("20").Range("A1:Z5000").PasteSpecial Paste:=xlPasteValues

Worksheets("Certify").AutoFilterMode = False
End Sub
 
Upvote 0
Try it like
Excel Formula:
Worksheets("20").Range("A1").PasteSpecial Paste:=xlPasteValues
 
Upvote 0
Hello, The code applies an autofilter on column F = 20 and column T = X , check the data in your table.

VBA Code:
Sub FILTER_COPY_PASTE()
Worksheets("Certify").Select

With ActiveSheet.Range("A1")
.AutoFilter Field:=6, Criteria1:="20" ' column F = 20
.AutoFilter Field:=25, Criteria1:="X" ' column Y = X
End With

Range("A1:Z5000").SpecialCells(xlCellTypeVisible).Copy
Worksheets("20").Range("A1:z5000").PasteSpecial Paste:=xlPasteValues

Worksheets("Certify").AutoFilterMode = False
Application.CutCopyMode = False

End Sub
 
Upvote 0
The code applies an autofilter on column F = 20 and column T = X
You sure about that ;) or is it a typo?

Also that will not prevent the problem the OP is getting.
 
Upvote 0
the user says it only copies one cell.
You can recreate the code, it works correctly, it only remains that the data does not contain the filter criteria.
Another way :
VBA Code:
Sub FILTER_COPY_PASTE()
 Application.ScreenUpdating = False
    With Worksheets("Certify").Range("A1").CurrentRegion
        .AutoFilter Field:=6, Criteria1:="20"
        .AutoFilter Field:=25, Criteria1:="X"
        
        Worksheets("20").Range("A1").CurrentRegion.Delete
        .SpecialCells(12).Copy Worksheets("20").Range("A1")
        .AutoFilter
    End With
 Application.ScreenUpdating = True
End Sub
File1 , File2
 
Upvote 0
Im sorry but that is stopping at the first autofilter when I try to run the macro.
.AutoFilter Field:=6, Criteria1:="20"
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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