我从其他来源复制的,并想粘贴到清除的工作表中
为什么不创建一个临时表并将数据粘贴到那里,然后清除所有表。完成后将数据从临时表复制到相关表并删除临时表?
看到这个(尝试和测试)
Sub clearly()
Dim ws As Worksheet, wsTemp As Worksheet
'~~> Create a Temp Sheet
Set wsTemp = Sheets.Add
'~~> Copy clipboad data to temp sheet
wsTemp.Range("A1").PasteSpecial xlPasteAll
'~~> Clear contents of all sheets except temp sheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> wsTemp.Name Then ws.Cells.ClearContents
Next ws
'~~> Copy data from temp sheet to relevant sheet
wsTemp.Cells.Copy Sheets("Sheet1").Cells
'~~> Delete temp sheet
Application.DisplayAlerts = False
wsTemp.Delete
Application.DisplayAlerts = True
End Sub