行と列、またはその逆に従業員とプロジェクトがあるとします。テーブルを「ピボット解除」した場合、それをピボットに戻して、グループ化を希望どおりに行うことができます。
私の Table2DB アドインをここでチェックしてください。
あなたの場合、以下のマクロを実行するだけで、新しいシートに基づいてピボットを作成できます
Sub UnPivot()
Dim lLastCol As Long, lLastRow As Long
Dim rgCell As Range, shtOrg As Worksheet, shtDest As Worksheet
Dim lRowDest As Long
'turn off updates to speed up code execution
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Set shtOrg = ActiveSheet
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row
lLastCol = Cells(48, Columns.Count).End(xlToLeft).Column
Set shtDest = Sheets.Add
lRowDest = 2
shtDest.Cells(1, 1) = "Project"
shtDest.Cells(1, 2) = "Employee"
With shtOrg
For Each rgCell In .Range(.Cells(49, 2), .Cells(lLastRow, lLastCol)).SpecialCells(xlCellTypeConstants)
If rgCell.Value = 1 Then
shtDest.Cells(lRowDest, 1) = .Cells(rgCell.Row, 1)
shtDest.Cells(lRowDest, 2) = .Cells(48, rgCell.Column)
lRowDest = lRowDest + 1
End If
Next rgCell
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
一緒に機能しなかったものを取得するには、以下に示すようにテーブルを作成し、式を使用します: =IF(COUNTIFS(OFFSET($A$49:$A$78,0,MATCH($A2,$48:$48,0)- 1,,),1,OFFSET($A$49:$A$78,0,MATCH(B$1,$48:$48,0)-1,,),1)>0,"した","しなかった" ) & " 共に働く"
