Large Data VBA, Conditional, Multiple Criteria Copy Row and Paste into Sheet at Speed

InfrequentVisitor

New Member
Joined
Mar 30, 2016
Messages
28
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello,

Using 2010 Excel, I have 192k rows and 6.5m filled cells of data that I need to be able to match certain criteria to and pull the matching rows from the data sheet into another sheet. It also needs to be as fast as possible (no looping?).

My research took me to these posts regarding AutoFilter:

Help Need VBA Code to copy rows to a new worksheet based on criteria
excel - VBA copy rows that meet criteria to another sheet - Stack Overflow

I've never dealt with AutoFilter before, but I did manage to get the code from the Mr. Excel post to match and copy rows to another sheet; however, my attempts to manipulate the code for my purpose resulted in only copying over the header of my table. I believe the AutoFilter codes in the linked forums only apply to a single column and I need to match within multiple columns.

Below is the criteria that a user inputs to determine how data is pulled.


Book1
ABCDEFGHIJK
1YearMonthCreatedAreaSectionAccountPurchase Order NumberPurchase Requisition NumberProject NumberTask Number
2201777/27/2017MATSF4611AA
Inquiry



- Columns A2:F2 should be the default look-up method.
----- A2:F2 should build upon each other to narrow the scope of the results.

- Columns H2:K2 should be independent of each other and A2:F2.
----- If H2 has a value, the look-up ignores all other criteria; same for I2, J2, or K2.

- All the criteria have their own column in the data table, Table1.

- The result is copied as entire rows from Table1 on the "Data" sheet and pasted into the "Inquiry" sheet where Table2's 1st row starts (cell A13).
----- I assume using a table is the easiest way to maintain a filter when posting the data.

- B2, D2, and E2 are lists, with D2 & E2 cascading lists, if it matters. I can change, if needed.

- I already coded deleting the result when executing a new inquiry, so no need for that.

Thank you for the help.

Respectfully,

Eric McDermott
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Solved.

This is the solution I used. It's quite fast considering the amount of data. I completely re-did how my inputs were arranged. I didn't actually need to have "IF" statements to prioritize a H2:K2 cell over any other input.

Code:
    Range("Table1[[#All],[Module Name]:[Month]]").AdvancedFilter Action:= _
        xlFilterCopy, CriteriaRange:=Sheets("Inquiry").Range("A1:E2"), CopyToRange _
        :=Sheets("Inquiry").Range("A17"), Unique:=False

- Eric
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,186
Members
452,615
Latest member
bogeys2birdies

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