Extract Data From Specific Columns That Meet Multiple Criteria

bradyman97

New Member
Joined
Feb 22, 2008
Messages
33
I have a sheet called Invoices below are the name of the columns. How can I extract data from columns E, G, K, L, D with criteria from column A and column B. Everytime I extract the data I need it go at the end of the previous data extracted. If it helps I have this advanced filtered VBA code below but it doesn't put it at the end of the previous month. Any help would be greatly appreciated.




A - Month/Year
B - Location
C - Vendor
D - PO #
E - PO Date
F - Line #
G - Vendor Item #
H - Description
I - Pack Description
J - Purchase Unit
K - Quantity
L - Price
M - Ext Amount
N - Notes



Sub Copy_Warehouse_Invoices() 'Module7


Dim rg As Range
Set rg = ThisWorkbook.Worksheets("Warehouse_Invoices").Range("A7").CurrentRegion

rg.Offset(1).ClearContents

Dim rgInvoices As Range, rgCriteria As Range, rgWarehouse_Invoices As Range


Set rgInvoices = ThisWorkbook.Worksheets("Invoices").Range("A1").CurrentRegion

Set rgCriteria = ThisWorkbook.Worksheets("Warehouse_Invoices").Range("A1").CurrentRegion

Set rgWarehouse_Invoices = ThisWorkbook.Worksheets("Warehouse_Invoices").Range("A7").CurrentRegion

rgInvoices.AdvancedFilter xlFilterCopy, rgCriteria, rgWarehouse_Invoices

Range("A7").CurrentRegion.Sort _
key1:=Range("B7"), order1:=xlAscending, _
key2:=Range("A7"), order2:=xlAscending, Header:=xlYes


Columns("A:E").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False

End With

With Selection.Font
.Name = "Arial"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With

Range("G7").Select


End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
The advanced filter replace the old value with the new values.
You can copy first the old values to a new tabel (copy-paste).
Or you can change your criteria incluse the previous selection. (2/2021 -> 2/2021 or 1/2021)
 

bradyman97

New Member
Joined
Feb 22, 2008
Messages
33
Say I already have filtered my data for January. I'm looking for a VBA code that when I change the criteria to February 2021 I would like to have put at the end of January 2021 data
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
Advanced Filter doesn't work that way. Filter it somewhere else, then copy those results onto the end of your already existing subset.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,594
Messages
5,637,299
Members
416,963
Latest member
zazama

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
Top