Filter 3 columns of data using 1 criteria, and copy to a different workbook

davellc

New Member
Joined
Dec 6, 2018
Messages
7
Hello,

I need to do the following:

Being in Workbook1, activate Workbook2 which contains the data below; filter the data in Columns A to C so that only the "c"'s in column a remain ; copy only the visible data and paste it into Workbook 1.
The number of rows that need to be filtered will vary from day to day and so will the number of "C" rows post filter.


Van TripStartEndOrdersNo. Of OrdersLaneC/OutLoadVan Reg.Driver
A05:0008:00
A05:0108:01
A05:0208:02
B05:0308:03
B05:0408:04
C05:0508:05
C05:0608:06
C06:1810:36
C06:2110:37

<colgroup><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

I have been unable to find a way to select the variable range to begin filtering and then apply the filter.

I have tried solutions from various sites including using DIM and Rng and trying to use that to autofilter (I run into an error with the field bit of "AutoFilter field:=1" "and attempted to modify them but my inexperience seems to be resulting in errors.

Thanks in advance for any help you can supply
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Is this what you mean?

Code:
Sub davellc()
Dim LR As Long
LR = Worksheets("WKBK2").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("WKBK2").Range("A1:J" & LR).AutoFilter Field:=1, Criteria1:="C"
Worksheets("WKBK2").Range("A1:J" & LR).SpecialCells(xlCellTypeVisible).Copy Sheets("WKBK1").Range("A1")
Worksheets("WKBK2").AutoFilterMode = False
End Sub
 
Upvote 0
Brilliant.

Worked first time and I have used this several times on other sheets already.

Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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