我假設你有行和列的員工和項目,反之亦然。如果您要「清理」桌面,則可以將其放回到關鍵位置,並按照您的需要進行分組。我的Table2DB插件here。
在你的情況,你可以簡單地運行下面的宏,並創建一個支點根據你的新工作表
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, 「難道」, 「沒有」)& 「同心協力」
![enter image description here](https://i.stack.imgur.com/1WRSl.png)
答案是怎麼回事被取消注意你的數據是如何組織的。我建議張貼截圖或數據樣本 - 因爲這似乎是一個非常基本的問題,我相信這裏有人可以幫助你。 – Stepan1010