一系列 Microsoft 試算表軟體,具有可用來對資料進行分析、製圖及通訊的工具。
你好,張書櫃
您可以使用此代碼來分佈總表中的資料:
Sub DistributeTasks()
Dim summaryWs As Worksheet
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim targetWs As Worksheet
Dim targetRow As Long
Set summaryWs = ThisWorkbook.Sheets("總表")
lastRow = summaryWs.Cells(Rows.Count, 1).End(xlUp).Row
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "總表" Then
ws.Range("A1:B" & ws.Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
End If
Next ws
For i = 1 To lastRow
On Error Resume Next
Set targetWs = ThisWorkbook.Sheets(summaryWs.Cells(i, 1).Value)
On Error GoTo 0
If Not targetWs Is Nothing Then
targetRow = targetWs.Cells(Rows.Count, 1).End(xlUp).Row + 1
targetWs.Cells(targetRow, 1).Value = targetRow
targetWs.Cells(targetRow, 2).Value = summaryWs.Cells(i, 2).Value
End If
Next i
End Sub
在總表中輸入內容,然後執行。
希望以上資訊能幫到您。如果您需要進一步幫助,請隨時發送消息。
最美好的祝願
Aiden.C - MSFT |Microsoft社群支援專家