Advanced filters & VBA code

John_Gil

New Member
Joined
Jun 3, 2020
Messages
42
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone! :)

I need to develop a macro that sums cases and packs (units) quantities from an exported file. The final document has the below aspect:

CasesUnits
WeekCases dispatchedCases forecastedCases orderedUnits despatchedUnits forecastedUnits ordered
35751777947892118785125137124681
Group A268027402746462724714947256
Group B274529203046450934866449939
Group C619695619109141223810914
Group D631566639597651866042
Group E167147167200417602004
Group F000000
Group G6757266758526101418526

Well each one of the groups have specific products associated what means that has to have specific filters from the exported file:
Group A - Filtered by "BACON" on column species and "OCADO" on column Sub-ProductTier;
Group B- Filtered by "Eden" on column Sub-ProductTier;
Group C- Filtered by "Organic" on column Sub-ProductTier;
Group D- Filtered by "PORK" on column species and "OCADO" on column Sub-ProductTier;
Group E- Filtered by "BACON" on column species;
Group F- Filtered by product code (RTO004, RTO005, RTO065, RTO008, RTO011,RTO012, RTO013);
Group G- Filtered by "LAMB" on column species and "OCADO" on column Sub-ProductTier;

The file from where this information needs to be taken has the below format:
ProductProductAreaCategorySpeciesSub-ProductTierProductTierCustomerFactTypeUnit
12/07/2020​
RTO140BURGERSFRESHBEEFOCADOCOREOCADO[Live] Combined HFI Forecast with PLM'sB
0​
RTO138SAUSAGEBREAKFASTPORKTESCO BRANDCOREOCADO[Live] Combined HFI Forecast with PLM'sB
0​
RTO137BURGERSFRESHBACONORGANICPREMIUMOCADO[Live] Combined HFI Forecast with PLM'sB
83​
RTO135JOINTFRESHLAMBEDENBRANDOCADO[Live] Combined HFI Forecast with PLM'sB
1​

The macro should first filter and then sum the cases and trays and present them into the first table.

Could you please help me with this guys? I'm just really starting to work with VBA and I would really appreciate your work.

Thank you,
John
 
If you're getting the result you want them that's ideal. My only issue with SUMIFS is the difficulty in changing them if you ever need to change anything.

There is just one right answer in Excel and w all use whatever works most easily for us.

??
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,216,031
Messages
6,128,424
Members
449,450
Latest member
gunars

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