|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 liclient 于 2018-1-24 23:52 编辑
代码如下,如果年份是2018,则运行正常,但是改为2017则报错,我不知道错在哪里
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Date < #3/20/2018# Then
Sheets(9).Activate
Sheets(9).Visible = -1
Sheets(9).Activate
Sheets(1).Visible = 2
Sheets(2).Visible = 2
Sheets(3).Visible = 2
Sheets(4).Visible = 2
Sheets(5).Visible = 2
Sheets(6).Visible = 2
Sheets(7).Visible = 2
Sheets(8).Visible = 2
Else
Sheets(9).Activate
Sheets(9).Visible = 2
Sheets(9).Activate
Sheets(1).Visible = -1
Sheets(2).Visible = -1
Sheets(3).Visible = -1
Sheets(4).Visible = -1
Sheets(5).Visible = -1
Sheets(6).Visible = -1
Sheets(7).Visible = -1
Sheets(8).Visible = -1
End If
ThisWorkbook.Save
End Sub
Private Sub Workbook_Open()
If Date < #3/20/2018# Then
MsgBox "欢迎使用"
Sheets(1).Visible = -1
Sheets(2).Visible = -1
Sheets(3).Visible = -1
Sheets(4).Visible = -1
Sheets(5).Visible = -1
Sheets(6).Visible = -1
Sheets(7).Visible = -1
Sheets(8).Visible = -1
Sheets(9).Activate
Sheets(9).Visible = 2
Else
Sheets(1).Visible = 2
Sheets(2).Visible = 2
Sheets(3).Visible = 2
Sheets(4).Visible = 2
Sheets(5).Visible = 2
Sheets(6).Visible = 2
Sheets(7).Visible = 2
Sheets(8).Visible = 2
Sheets(9).Activate
Sheets(9).Visible = -1
End If
End Sub
|
|