简体   繁体   English

如何重新排列和分组表中的数据

[英]How to re-arrange and group data from a table

I have a sheet with 4 columns: Date, Shift, Good-Parts, Bad-parts... Not all dates have all 3 shifts worth of data.我有一个包含 4 列的工作表:日期、班次、好部分、坏部分……并非所有日期都包含所有 3 个班次的数据。 what I want to do is re-arrange the data so that each date is a single row with good and bad part qty's for each recorded shift displayed to the right.我想要做的是重新排列数据,以便每个日期都是一行,每个记录的班次显示的好坏部分数量显示在右侧。

change this:  
Date, 1st, Good, Bad  
Date, 2nd, Good, Bad  
Date, 3rd, Good, Bad  
Date, 1st, Good, Bad  
Date, 1st, Good, Bad  
Date, 1st, Good, Bad  
Date, 2nd, Good, Bad


to this:  
      1st Shift  2nd Shift  3rd Shift  
Date, Good, Bad, Good, Bad, Good, Bad  
Date, Good, Bad,  
Date,                       Good, Bad  
Date, Good, Bad, Good, Bad  

how do I create a Macro that can scan down the 2nd column and move the 2 data cells for each 2nd and 3rd shift record up to the appropriate date row in the appropriate shift columns...我如何创建一个宏,它可以向下扫描第二列并将每个第二和第三个班次记录的 2 个数据单元格向上移动到相应班次列中的相应日期行...

示例表

@DirkReichel is right, this is a pretty simple PivotTable. @DirkReichel 是对的,这是一个非常简单的数据透视表。

Here is some mock data I made这是我制作的一些模拟数据
模拟数据

After selecting that data and clicking Insert > PivotTable , I moved the headers like this - columns : shift, rows : day, values : good, bad.选择该数据并单击Insert > PivotTable ,我移动了这样的标题 -:移位,:天,:好,坏。
在此处输入图片说明
(Excel included the 'sum of values" bit into the columns list on its own) (Excel 自行将“值的总和”位包含在列表中)

And here was the result这是结果
在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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