Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel转置-基于单元格值_Excel_Transpose_Excel Vba - Fatal编程技术网

Excel转置-基于单元格值

Excel转置-基于单元格值,excel,transpose,excel-vba,Excel,Transpose,Excel Vba,我一直试图找到一种方法,在excel中只将某些列转换为行,以获得我的结果 因为我需要输出文本值,所以无法使用透视表。这是所附的图片,显示了我所拥有的和我所需要的 如有任何见解,将不胜感激 < /P> < P>请根据您的示例考虑以下解决方案: G3=IF(SUMIFS($C$4:$C$13,$A$4:$A$13,$F4,$B$4:$B$13,G$3)>0,SUMIFS($C$4:$C$13,$A$4:$A$13,$F4,$B$4:$B$13,G$3),"") 这假设“项目ID”和“扫描事

我一直试图找到一种方法,在excel中只将某些列转换为行,以获得我的结果

因为我需要输出文本值,所以无法使用透视表。这是所附的图片,显示了我所拥有的和我所需要的

如有任何见解,将不胜感激


< /P> < P>请根据您的示例考虑以下解决方案:

G3=IF(SUMIFS($C$4:$C$13,$A$4:$A$13,$F4,$B$4:$B$13,G$3)>0,SUMIFS($C$4:$C$13,$A$4:$A$13,$F4,$B$4:$B$13,G$3),"")
这假设“项目ID”和“扫描事件ID”的每个组合只显示一次。这使我们可以使用
SUMIFS
函数将唯一相关的结果相加。请注意,excel会根据该日期序列号进行添加

if用于防止Excel显示返回0并被解析为实际日期的公式

然后将公式拖到输出表的其余部分。关于,

您没有指定技术标签,但我发现,如果您允许某些参数是动态的,这些是最好的解决方案;e、 g.根据原始数据的大小和性质进行分配

Sub collate()
    Dim rw As Long, rc As Long, rr As Long, r As Long, c As Long

    With Sheets("Sheet2")    '<-set this worksheet reference properly!
        rr = Application.Match("item id", .Columns(1), 0)
        rc = .Cells(rr, Columns.Count).End(xlToLeft).Column + 2
        .Cells(rr, rc + 1) = .Cells(rr + 1, 2).Value2

        For rw = rr + 1 To .Cells(Rows.Count, 1).End(xlUp).Row
            If IsError(Application.Match(.Cells(rw, 1).Value2, .Columns(rc), 0)) Then
                .Cells(Rows.Count, rc).End(xlUp).Offset(1, 0) = .Cells(rw, 1).Value2
            End If
            If IsError(Application.Match(.Cells(rw, 2).Value2, .Cells(rr, rc).Resize(1, 999), 0)) Then
                .Cells(rr, Columns.Count).End(xlToLeft).Offset(0, 1) = .Cells(rw, 2).Value2
            End If

            r = Application.Match(.Cells(rw, 1).Value2, .Columns(rc), 0)
            c = Application.Match(.Cells(rw, 2).Value2, .Rows(rr), 0)
            .Cells(r, c) = .Cells(rw, 3).Value
        Next rw

        With .Cells(rr, rc).CurrentRegion
            With .Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0)
                 .Cells.Sort Key1:=.Columns(1), Order1:=xlAscending, _
                            Orientation:=xlTopToBottom, Header:=xlNo
            End With
            With .Resize(.Rows.Count, .Columns.Count - 1).Offset(0, 1)
                 .Cells.Sort Key1:=.Rows(1), Order1:=xlAscending, _
                            Orientation:=xlLeftToRight, Header:=xlNo
            End With
        End With

    End With
End Sub
Sub-collate()
变暗rw为长,rc为长,rr为长,r为长,c为长

对于Sheets(“Sheet2”)“这将不是一个转置,因为您的元素会在结果表中重新引用。这是一次性流程还是定期完成的任务?您可以使用
MATCH
INDEX
提取与听者匹配的时间戳。