运行宏,提示错误-2147417848(80010108)
下面是具体的宏,红色部分就是报错地方。但是这个代码在其他excel就能用。这个功能是财务月报用的。其他分公司也用这个代码,但只有三、四家公司报错
大神们,请问知道这什么原因吗
Sub insert()
Dim Message, Title, Default, rownum
Message = "请输入需要插入的行数,行数范围从1至1000,当前默认行数为1。"
Title = "输入行数"
Default = "1"
rownum = InputBox(Message, Title, Default)
If rownum = "" Then
End
Else
sheetname = Range("Y4")
sheetaccess = Range("Y3")
msg_num = "B" & Range("Y11") - 1
If sheetaccess = "F" Then
MsgBox "本月数据已经被保护!"
Else
For j = 1 To rownum
ActiveSheet.Unprotect Password:="dtwfin0936"
ActiveWorkbook.Unprotect Password:="dtwfin0936"
Sheets("Backup").Visible = True
Sheets("Backup").Select
Range("A11:X11").Select
Selection.Copy
'Rows("11:11").Copy
'ActiveWindow.ScrollColumn = 1
Select Case sheetname
Case 1
Sheets("1").Select
Case 2
Sheets("2").Select
Case 3
Sheets("3").Select
Case 4
Sheets("4").Select
Case 5
Sheets("5").Select
Case 6
Sheets("6").Select
Case 7
Sheets("7").Select
Case 8
Sheets("8").Select
Case 9
Sheets("9").Select
Case 10
Sheets("10").Select
Case 11
Sheets("11").Select
Case 12
Sheets("12").Select
End Select
ins_num = "A" & Range("Y11")
Range(ins_num).insert Shift:=xlDown
Range("Y11") = Range("Y11") + 1
ActiveSheet.Protect Password:="dtwfin0936", DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Backup").Visible = False
ActiveWorkbook.Protect Password:="dtwfin0936"
Next j
End If
End If
End Sub