Dim wkbkdestination As Workbook
Dim destsheet As Worksheet
For Each ThisWorkSheet In wkbkorigin.Worksheets
'this throws subscript out of range if there is not a sheet in the destination
'workbook that has the same name as the current sheet in the origin workbook.
Set destsheet = wkbkdestination.Worksheets(ThisWorkSheet.Name)
Next
基本上,我遍历原始工作簿中的所有工作表,然后destsheet
在目标工作簿中将其设置为与原始工作簿中当前迭代的工作表具有相同名称的工作表。
如何测试该表是否存在?就像是:
If wkbkdestination.Worksheets(ThisWorkSheet.Name) Then