|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
修改后代码:
Sub auto_open()
Application.ScreenUpdating = False
On Error Resume Next
Application.EnableEvents = False
Application.AskToUpdateLinks = False
a = Format(Now, "yymm")
If ActiveSheet.Name = a Then
Exit Sub
End If
Sheets(a).Select
End Sub
Sub ModiName()
Application.ScreenUpdating = False
On Error Resume Next
Dim a$, b1$, b2$, i%
If Right(Sheets(1).Name, 2) <> "01" Or Right(Sheets(12).Name, 2) <> "12" Then
MsgBox "应将1~12月份报表放在本工作簿文件的前列"
Exit Sub
End If
a = Right(Sheets("操作说明").Range("C5"), 2)
For i = 1 To 12
If i < 9 Then
b1 = 0 & i + 1
Else
b1 = i + 1
End If
If i < 11 Then
b2 = 0 & i - 1
Else
b2 = i - 1
End If
Sheets(i).Select
Sheets(i).Name = a & Right(Sheets(i).Name, 2)
ActiveSheet.Unprotect
If i < 12 Then
Range("E5").Hyperlinks(1).SubAddress = "'" & a & b1 & "'!_MONTHLY"
End If
If i > 1 Then
ActiveSheet.Shapes("Rectangle 5").Select
Selection.ShapeRange.Item(1).Hyperlink.SubAddress = "'" & a & b2 & "'!_MONTHLY"
End If
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
Next i
Sheets(1).Select
End Sub |
|