请你能帮助-我目前得到一个下标超出范围的错误时,vba得到“tb.sheets(shName)。复制”,我不能弄清楚为什么-任何支持将不胜感激!谢谢你
Sub Create_Consolidated_File()
Dim tB As Excel.Workbook
Dim wB As Excel.Workbook
Dim ExportArray As Variant
Dim ShName As Variant
Dim ExportName As String
Dim varResult As Variant
Dim Attachments As Range
Set Attachments = Range("D3:E28")
For Each Row In Attachments
For Each cell In Row
Set tB = ThisWorkbook
ExportArray = Array(cell.Value) 'work on this bit to define as the sheet names in columns D & E
For Each ShName In ExportArray
tB.Sheets(ShName).Copy
1条答案
按热度按时间omtl5h9j1#
如果工作表名称为数字,则使用CStr将其转换为字符串。我还添加了一些语法来完成您提供的代码。