|
|
本帖最后由 brother 于 2025-12-3 10:38 编辑
很好用的日历,请问如何用代码实现一打开表格“月历”,就默认显示当前月的月历?
2025-12-3:
已解决,在组合框内插入按钮,代码如下:
- <div>Private Sub 按钮1446_Click()
- Dim currentYear%, currentMonth$
- Dim yearRow As Byte, monthRow As Byte
-
- currentYear = Format(Date, "yyyy")
- currentMonth = Format(Date, "m") & "月"
-
- With Sheets("UserForm")
- yearRow = Application.Match(currentYear, .Range("D4:D15"), 0)
- monthRow = Application.Match(currentMonth, .Range("B4:B15"), 0)
-
- If Not IsError(yearRow) Then .Range("D2").Value = yearRow
- If Not IsError(monthRow) Then .Range("B2").Value = monthRow
- End With
- End Sub</div>
复制代码
|
|