|
在Thisworkbook模块里添加代码
- Private Sub Workbook_SheetActivate(ByVal Sh As Object)
- Dim oData As Object, nMonth As Long, nDay As Long, nYear As Long, dDate As Date
- With CreateObject("Vbscript.RegExp")
- .Global = True
- .IgnoreCase = True
- .Pattern = "(\d+)\.(\d+)"
- Set oData = .Execute(Sh.Name)
- If oData.Count > 0 Then
- nYear = Year(Now())
- nMonth = Val(oData(0).SubMatches(0))
- nDay = Val(oData(0).SubMatches(1))
- dDate = DateSerial(nYear, nMonth, nDay)
- If nYear = Year(dDate) And nMonth = Month(dDate) Then
- Application.ScreenUpdating = False
- Application.EnableEvents = False
- [Q3] = Format(dDate, "YYYY年MM月DD日")
- Application.ScreenUpdating = True
- Application.EnableEvents = True
- End If
- End If
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|