EXCEL运行错误 1004

来源:百度知道 编辑:UC知道 时间:2024/05/24 18:56:21
Sub 部门明细报表()
Dim i As Integer, j As Integer, bmrow1 As Integer, temp As Integer
Dim bmmxrow As Integer, lbrow As Integer, ckrow As Integer
Dim je As Single
Dim Message, Title, Default, MyValue
Title = " 友情提醒 --by heaven"

Message = " 请确认期间已经输入正确!"

MyValue = MsgBox(Message, 1, Title)
If MyValue = 1 Then

bmrow1 = Sheets("基本资料").[i65536].End(xlUp).Row

bmmxrow = Sheets("部门明细报表").[b65536].End(xlUp).Row

Application.ScreenUpdating = False

With Sheets("部门明细报表")
'清除设置
If bmmxrow > 2 Then
Range("a3:i" & bmmxrow & "").ClearContents
ActiveSheet.ResetAllPageBreaks
End If

j = 3

For i = 3 To bmrow1 + 1 '部门循环
.Cells(j, 2) = Sheets("基本资料").Cells(i - 1, 9)
temp = j
ckrow = 2
Do While Not (IsEmpty(Sheets("出库数据").Cells(ckrow, 1)))

If

是下标越界把 八成是因为文件路径的问题
建议像“Sheets("基本资料").”这种前面加上ActiveWorkbook.变成

ActiveWorkbook.WorkSheets("基本资料").XXX

不懂问我吧。