如何在Excel中将长格式表转换为宽格式表?

时间:2014-06-26 06:27:23

标签: excel function

一张图片胜过千言万语。让我们在一张表中说我有下表:

enter image description here

使用这些信息,我想在另一张表格中以编程方式生成这样的表格(将长表解压缩为宽表格):

enter image description here

你怎么能实现这个目标?

2 个答案:

答案 0 :(得分:2)

使用VBA:

Range("G1:K99").Clear
For Each xx In Range("A:A")
    If xx.Value = "" Then Exit Sub
    Range("G1").Offset(xx.Value, 0) = xx.Value
    For e = 1 To 99
        If Range("G1").Offset(xx.Value, e) = "" Then
            Range("G1").Offset(xx.Value, e) = xx.Offset(0, 1).Value
            Exit For
        End If
    Next
Next

从“G”列创建的表格。如果你想要另一张纸:

Sheets(2).Range("G1: ...

在...之前添加表格 没有VBA,遵循该计划:

enter image description here

添加公式:

M2 -> =IFERROR(MATCH(L2;$A$1:$A$8;);"")
N2 -> =IFERROR(MATCH(L2;INDIRECT("$A" & (M2+1) & ":$A$8");)+M2;"")
O2 -> =IFERROR(MATCH(L2;INDIRECT("$A" & (N2+1) & ":$A$8");)+N2;"")
P2 -> =IFERROR(INDEX($B$1:$B$8;M2);"")          Autocomplete also columns to R

和自动填充...

答案 1 :(得分:1)

我也可以看到另一种方法。添加两列Count和Key。

Example

添加公式并展开:

    public void notify(View view){
    notification.setSmallIcon(R.drawable.ic_stat_name);
    notification.setTicker("Welcome to ****");
    notification.setWhen(System.currentTimeMillis());
    notification.setContentTitle("abcd");
    notification.setContentText("abcd");


    Intent intent = new Intent(this, home.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    notification.setContentIntent(pendingIntent);


    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.notify(uniqueID, notification.build());
}