MS excel进行子表/智能分组

时间:2017-05-26 10:57:31

标签: excel vba excel-vba grouping

我在MS Excel(2016)中有2个数据表,需要分析2张中的数据。以下是我需要的示意性问题:

() - sheet1 - main

---------------------------
| id | product | manuf | q | 
---------------------------
| 001| prt_1   | man_1 |150|
---------------------------
| 002| prt_2   | man_2 |800|

() - sheet2 - submain

--------------------
|id | date | prices|
--------------------
|001|17.01 | 120   |
--------------------
|001|16.02 | 99    |
--------------------
|002|17.03 | 110   |
--------------------
|002|15.02 | 10    |

() - 我想要做的就是将它们分组,就像这样

---------------------------
| id | product | manuf | q |
---------------------------
- | 001| prt_1   | man_1 |150|
  ----------------------------
   |001|17.01 | 120   |
   --------------------
   |001|16.02 | 99    |

---------------------------
+ | 002| prt_2   | man_2 |800|

换句话说,它是MS Access SubDataSheet的模拟,我知道如何在Acces中执行它,但需要在excel中。 我尝试了数据透视表和动力枢轴,但仍然没有运气。

第二个变体是相同的任务,但另一个版本的源数据。而不是2张所有数据在一个,但行加倍和三倍。不知道哪种变体更适合做所需的分组。

--------------------------------------------
| id | product | manuf | q |  date | prices|  
--------------------------------------------
|001 | prt_1   | man_1 |150| 17.01 | 120   |
--------------------------------------------
|001 | prt_1   | man_1 |150| 16.02 | 99    |

是否有一些VBA代码可以执行此操作? nees帮助和建议。

1 个答案:

答案 0 :(得分:2)

类似这样的事情

javax.el.PropertyNotWritableException: The class 'java.util.HashMap$Node' does not have a writable property 'key'.

<p:dataTable id="breaktime" var="item" value="#{breakTimeDataActions.map.entrySet().toArray()}"
    editable="true" editMode="cell" >

    <f:facet name="header">
    </f:facet>

    <p:ajax event="cellEdit" listener="#{breakTimeDataActions.onCellEdit}"
    update=":form:msgs" />

    <p:column headerText="#{texts['breaktime.hours']}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{item.key}" />
            </f:facet>
            <f:facet name="input">
                <p:spinner  value="#{item.key}" min="0" max="24"  converter="javax.faces.Integer" />
            </f:facet>
        </p:cellEditor>
    </p:column>

    <p:column headerText="#{texts['breaktime.minute']}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{breakTimeDataActions.map[item.key]}" />
            </f:facet>
            <f:facet name="input">
                <p:spinner value="#{breakTimeDataActions.map[item.key]}" min="0" max="24"  converter="javax.faces.Integer" />
            </f:facet>
        </p:cellEditor>
    </p:column>
</p:dataTable>