【发布时间】:2011-10-05 00:17:56
【问题描述】:
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
【问题讨论】: