Copy all filtered data

thardin

Board Regular
Joined
Sep 29, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Here is the code I have so far to filter data. But I wasn't sure, if I did this effectively with ".UsedRange."
What I want to do is filter the data using a range that changes daily, copy only the filtered data(not the headings), and paste into another worksheet starting in cell A2.

What do you recommend?

Sub Filter()

Range("Q6").Select
Selection.AutoFilter
ActiveSheet.UsedRange.AutoFIlter Field:=17, Criteria1=Array("C",_ "C1", "C2", "L"), Operator:=xlFilterValues

EndSub
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Do you have any blank rows in your data?
Also what row contains the headers?
 
Upvote 0
Do you have any blank rows in your data?
Also what row contains the headers?
Yes. The range of my data is from A to Q with more than 2,000 rows (that changes daily). Column M and P have a lot of blank cells which makes copying kinda tricky using the crtl + arrow keys.
 
Upvote 0
Yes. The range of my data is from A to Q with more than 2,000 rows (that changes daily). Column M and P have a lot of blank cells which makes copying kinda tricky using the crtl + arrow keys.
Do you have any blank rows in your data?
Also what row contains the headers?
I don't have any blank rows, just blank cells.
the first row is the headers.
 
Upvote 0
Ok, how about
VBA Code:
Sub thardin()
   With ActiveSheet
      .Range("A1:Q1").AutoFilter 17, Array("C", "C1", "C2", "L"), xlFilterValues
      .AutoFilter.Range.Offset(1).Copy Sheets("Sheets2").Range("A2")
      .AutoFilterMode = False
   End With
End Sub
Change the destination sheet name to suit.
 
Upvote 0
Solution
Well how do I add an IF Then statement to this, in order to do this task only when the filter has results and if it doesn't, I want to run this macro:

Application.Run "personal. Xlsb! FirmSignoff
 
Upvote 0
As that a different question, it needs a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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