gpt4 book ai didi

VBA - 创建新工作表并重命名

转载 作者:行者123 更新时间:2023-12-04 21:11:55 29 4
gpt4 key购买 nike

我正在尝试插入一个新工作表,然后只需一个按钮即可将其重命名为当前月份和年份。有关一些额外信息:我计划稍后删除此按钮,以便它是自动的。

Private Sub CommandButton1_Click()

nowMonth = Month(Now)
nowYear = Year(Now)

ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)Name = "nowMonth & , & nowYear)

End Sub

最佳答案

这将做到:

nowMonth = Month(Now)
nowYear = Year(Now)

ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveWorkbook.Sheets(Worksheets.Count).Name = nowMonth & "," & nowYear

关于VBA - 创建新工作表并重命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46967251/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com