excel运行时错误1004
Sub合并当前目录下所有工作簿的全部工作表()DimMyPath,MyName,AWbNameDimWbAsWorkbook,WbNAsStringDimGAsLongD...
Sub 合并当前目录下所有工作簿的全部工作表()
Dim MyPath, MyName, AWbName
Dim Wb As Workbook, WbN As String
Dim G As Long
Dim Num As Long
Dim BOX As String
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.xls")
运行这个的时候出现错误
AWbName = ActiveWorkbook.Name
Num = 0
Do While MyName <> ""
If MyName <> AWbName Then
Set Wb = Workbooks.Open(MyPath & "\" & MyName)
Num = Num + 1
With Workbooks(1).ActiveSheet
.Cells(.Range("B65536").End(xlUp).Row + 2, 1) = Left(MyName, Len(MyName) - 4)
For G = 1 To Sheets.Count
Wb.Sheets(G).UsedRange.Copy .Cells(.Range("B65536").End(xlUp).Row + 1, 1)
Next
WbN = WbN & Chr(13) & Wb.Name
Wb.Close False
End With
End If
MyName = Dir
Loop
Range("B1").Select
Application.ScreenUpdating = True
MsgBox "共合并了" & Num & "个工作薄下的全部工作表。如下:" & Chr(13) & WbN, vbInformation, "提示"
End Sub 展开
Dim MyPath, MyName, AWbName
Dim Wb As Workbook, WbN As String
Dim G As Long
Dim Num As Long
Dim BOX As String
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.xls")
运行这个的时候出现错误
AWbName = ActiveWorkbook.Name
Num = 0
Do While MyName <> ""
If MyName <> AWbName Then
Set Wb = Workbooks.Open(MyPath & "\" & MyName)
Num = Num + 1
With Workbooks(1).ActiveSheet
.Cells(.Range("B65536").End(xlUp).Row + 2, 1) = Left(MyName, Len(MyName) - 4)
For G = 1 To Sheets.Count
Wb.Sheets(G).UsedRange.Copy .Cells(.Range("B65536").End(xlUp).Row + 1, 1)
Next
WbN = WbN & Chr(13) & Wb.Name
Wb.Close False
End With
End If
MyName = Dir
Loop
Range("B1").Select
Application.ScreenUpdating = True
MsgBox "共合并了" & Num & "个工作薄下的全部工作表。如下:" & Chr(13) & WbN, vbInformation, "提示"
End Sub 展开
1个回答
展开全部
可能是软件出错了。建议重新下载安装看看,
Office 2016破解版安装方法
1、首先,第一步我们需要将下载好的Office 2016解压缩,解压后,双击运setup.exe;
2、现在呢,我们能做的只有等,不过很快,不用多久,这里有个前提,就是必须要将你电脑上之前的office相关软件全都卸载干净在安装office 2016,不然安装会出错,如果还是失败,你就继续安装,可能一次不成功,这是正常的;
3、好的office安装完成,现在我们点击关闭。
Office 2016 破解版:http://www.xue51.com/soft/808.html
Office 2016破解版安装方法
1、首先,第一步我们需要将下载好的Office 2016解压缩,解压后,双击运setup.exe;
2、现在呢,我们能做的只有等,不过很快,不用多久,这里有个前提,就是必须要将你电脑上之前的office相关软件全都卸载干净在安装office 2016,不然安装会出错,如果还是失败,你就继续安装,可能一次不成功,这是正常的;
3、好的office安装完成,现在我们点击关闭。
Office 2016 破解版:http://www.xue51.com/soft/808.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |