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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
two thoughts:

1. I think you're more likely to use PowerQuery (might not need that step) and Power Pivottable than VBA (which would be difficult to create and a nightmare to adapt/change).
2. Can you use the XL2BB to post your data as it is then easy to import it and try different solutions before responding to you.

HTH
 
Upvote 0
Hi Pjmorris!

I have installed the add in but for some reason it does not let me to select the information and I get an error (I attached an image with the error) :/
 

Attachments

  • Add-in error.JPG
    Add-in error.JPG
    139.5 KB · Views: 31
Upvote 0
Looks to me as if you need your IT team to allow macros - even our security cleared company allowed them.
 
Upvote 0
I will check with my IT team Peter and I come back to you. Thank you! :)
 
Upvote 0
an alternative is to publish a redacted version using Dropbox (use Randombetween in data columns to provide nonsense numbers) - though I can imagine they'll go ballistic at that idea! The aim will be to have two tables: your source data with sufficient detail to create the output table. If you look at the output above it makes complete sense, but the source table doesn't contain enough information to be able to create the output, for example no cases dispatched, forecast or ordered, and no units dispatched, forecast or ordered; though presumably the relationship between cases and units could be obtained from a lookup table.

HTH
 
Upvote 0
Will do this Peter I have all that information the source table has more than 1500 rows! Tomorrow morning I will get it posted and I will try to use Dropbox as you said. Really appreciate your help!
 
Upvote 0
Hi Peter! In order to share my files from dropbox I need your email or is there an other way? Thanks!
 
Upvote 0
Hi John,

You should be able to create a link in Dropbox that when posted here will allow me to see that file. It doesn't allow me to see the folder or anything other than that file. It would also have the benefit of allowing others to see the source data and perhaps offer an alternative solution - there is often a multitude of ways of doing something in Excel.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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