EXCEL表在运行宏时总出现"运行时错误1004"方法"save"作用于对象"-wrokbook"时失败
EXCEL表在运行宏时总出现"运行时错误1004"方法"save"作用于对象"-wrokbook"时失败代码如下:Sub新增课时()DimiAsInteger,jAsIn...
EXCEL表在运行宏时总出现"运行时错误1004"方法"save"作用于对象"-wrokbook"时失败
代码如下:
Sub 新增课时()
Dim i As Integer, j As Integer, a As String, b As String, c As String, d As String, e As String, f As String, g As String
Worksheets("考勤登记表").Activate
z = Cells(4, 2).Value
a = Cells(12, 3).Value
b = Cells(12, 4).Value
c = Cells(12, 5).Value
d = Cells(12, 6).Value
e = Cells(12, 7).Value
f = Cells(12, 8).Value
g = Cells(12, 9).Value
h = Cells(12, 10).Value
Worksheets("学员信息汇总").Activate
Sheets("学员信息汇总").Unprotect
For j = 1 To 10000
If Cells(j, 1).Value = z Then
i = Cells(j, 1).End(xlToRight).Column
Cells(j, i + 1).Activate
Cells(j, i + 1).Value = a
Cells(j, i + 2).Activate
Cells(j, i + 2).Value = b
Cells(j, i + 3).Activate
Cells(j, i + 3).Value = c
Cells(j, i + 4).Activate
Cells(j, i + 4).Value = d
Cells(j, i + 5).Activate
Cells(j, i + 5).Value = e
Cells(j, i + 6).Activate
Cells(j, i + 6).Value = f
Cells(j, i + 7).Activate
Cells(j, i + 7).Value = g
Cells(j, i + 8).Activate
Cells(j, i + 8).Value = h
End If
Next j
Sheets("学员信息汇总").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
Worksheets("考勤登记表").Activate
Sheets("考勤登记表").Unprotect
Sheets("考勤登记表").Range("C12:J12").Select
Selection.ClearContents
Sheets("考勤登记表").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
ActiveWorkbook.Save
End Sub 展开
代码如下:
Sub 新增课时()
Dim i As Integer, j As Integer, a As String, b As String, c As String, d As String, e As String, f As String, g As String
Worksheets("考勤登记表").Activate
z = Cells(4, 2).Value
a = Cells(12, 3).Value
b = Cells(12, 4).Value
c = Cells(12, 5).Value
d = Cells(12, 6).Value
e = Cells(12, 7).Value
f = Cells(12, 8).Value
g = Cells(12, 9).Value
h = Cells(12, 10).Value
Worksheets("学员信息汇总").Activate
Sheets("学员信息汇总").Unprotect
For j = 1 To 10000
If Cells(j, 1).Value = z Then
i = Cells(j, 1).End(xlToRight).Column
Cells(j, i + 1).Activate
Cells(j, i + 1).Value = a
Cells(j, i + 2).Activate
Cells(j, i + 2).Value = b
Cells(j, i + 3).Activate
Cells(j, i + 3).Value = c
Cells(j, i + 4).Activate
Cells(j, i + 4).Value = d
Cells(j, i + 5).Activate
Cells(j, i + 5).Value = e
Cells(j, i + 6).Activate
Cells(j, i + 6).Value = f
Cells(j, i + 7).Activate
Cells(j, i + 7).Value = g
Cells(j, i + 8).Activate
Cells(j, i + 8).Value = h
End If
Next j
Sheets("学员信息汇总").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
Worksheets("考勤登记表").Activate
Sheets("考勤登记表").Unprotect
Sheets("考勤登记表").Range("C12:J12").Select
Selection.ClearContents
Sheets("考勤登记表").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True '
ActiveWorkbook.Save
End Sub 展开
3个回答
展开全部
没有数据 运行不起来
Application.DisplayAlerts = False
加上这个试下
应该是保存代码因为某些原因冲突了吧
Application.DisplayAlerts = False
加上这个试下
应该是保存代码因为某些原因冲突了吧
更多追问追答
追问
加在什么位置呢?
追答
开头吧 感觉应该不可以 应该是 保存代码和什么冲突了
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
好强大的代码~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询