Help Unable to copy data using filter

sanz

Board Regular
Joined
Jul 19, 2011
Messages
58
Hi All,

I am trying to apply filter to the code and need to copy and paste the data in the Last row of the second sheet.

Below is the code i am facing issue with, data is getting freeze in the second sheet.

Dim sh4 As Worksheet, rng As Range, LR As Long
Set sh4 = Workbooks("Book6.xlsx").Worksheets("Sheet1")
Range("A1").AutoFilter Field:=1, Criteria1:="#N/A"
Range("A1").AutoFilter Field:=3, Criteria1:=">=5"
Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0).Select
ActiveWindow.FreezePanes = True
Set rng = sh4.Range("A2:A")
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste


Is there any alternative method/macro to copy and paste filtered data to last row in second sheet.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
you can avoid all the select with this

Code:
sh4.Range("A2:A").copy destination:=sheets("Sheet2").range("A1")
[/COLOR][COLOR=#333333]
 
Upvote 0
Thanks for your replay storm,

But i am still unable to paste the data in sheet2
 
Upvote 0
Range("A2:A") seems as invalid range.
I guess you want range("A2").resize(range("A2").end(xldown).row-1,1)
 
Upvote 0

Forum statistics

Threads
1,203,460
Messages
6,055,556
Members
444,797
Latest member
18ecooley

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