简体   繁体   中英

Calculate count of type in one column for each date in other column using Excel VBA

I am trying a macro to give me count of columnA containing type of elements per date in columnB. I need to multiply each type count with certain value(volume calculation) and keep total per type per date in new sheet.

Sample data:

Large        12/12/2016  
Large        12/12/2016
Medium       12/12/2016
Medium       12/12/2016
Medium       12/12/2016
Medium       12/12/2016
Medium       12/12/2016
Medium       12/12/2016    
Medium       12/12/2016
Small        12/12/2016
Large        12/12/2016
Extra Large  12/12/2016
Extra Large  12/12/2016
Extra Large  12/12/2016

Here is my thought process for algorithm.

  1. Loop each row and try to group dates and find count of each date and paste it in new cell and replace if same date is found again.

  2. Loop from min date to max date. Fetch all rows for current date and find count of them and place it in new sheet for each date

Is this doable using any of the above? If not can some one help me with new algorithm possible pseudo code. Please ignore if you feel naive.

Here is the pivot table that made with your sample data. Also, I made a video so you can see how to create it. With more data you can see you can do much more stuff. If this is what you were looking for, please hit the checkmark next to this answer to mark it.

File:

http://www.filedropper.com/pivot

Video:

https://www.screencast.com/t/BJBUIJPu76

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM