我一直在试图找出一种方法来将excel中的某些列转换为行,以实现我的结果。Excel Transpose - 基于单元格值
由于我需要的输出是文本值,我一直无法使用数据透视表我的目的。这是附加的图像,显示我有什么和我需要什么。
任何有识之士将不胜感激!
我一直在试图找出一种方法来将excel中的某些列转换为行,以实现我的结果。Excel Transpose - 基于单元格值
由于我需要的输出是文本值,我一直无法使用数据透视表我的目的。这是附加的图像,显示我有什么和我需要什么。
任何有识之士将不胜感激!
请考虑以下解决方案按您的例子。
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),"")
这里假设“Item ID”和“Scan Event ID”的每个组合只显示一次。这使我们能够使用SUMIFS
函数加上唯一相关的结果。请注意,Excel根据该日期序列号添加它。
该if是为了防止Excel显示公式返回0并被解析为实际日期。
然后,您将公式拖到输出表的其余部分。问候,
您没有指定一个excel-vba技术标签,但我发现这些是最好的解决方案,只要你允许某些参数是动态的;例如根据原始数据的大小和性质分配。
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
在对您的数据进行大致的重复运行后,我想出了这些结果。
注意,我已明确改变,以证明对所得数据执行水平排序例程与乱序3005条目的数据。
这不会是一个转置,因为你的元素在你的结果表中被使用。这是一个关闭过程还是定期完成的任务?你可以使用'MATCH'和'INDEX'来提取匹配你的听众的时间戳。 – nbayly