Excel & OneNote 現(xiàn)已加入Copilot體驗全家桶

在sheet3中實時合并sheet1和sheet2的內(nèi)容。

=IFERROR(INDEX(Sheet1!$A$1:$Z$100, ROW()-ROW($A$1)+1, COLUMN()), IFERROR(INDEX(Sheet2!$A$1:$Z$100, ROW()-ROW($A$1)+1, COLUMN()), ""))
Sub MergeSheets()
??Dim ws As Worksheet
??Dim wsMerged As Worksheet
???
??Application.ScreenUpdating = False
???
??Set wsMerged = ThisWorkbook.Sheets.Add(After:=Sheets(Sheets.Count))
??wsMerged.Name = "Merged"
???
??For Each ws In ThisWorkbook.Worksheets
????If ws.Name <> "Merged" Then
??????ws.UsedRange.Copy wsMerged.Cells(wsMerged.Cells(Rows.Count, 1).End(xlUp).Row + 1, 1)
????End If
??Next ws
???
??Application.ScreenUpdating = True
End Sub
標(biāo)簽: