【问题标题】:Excel rename sheets consecutively with VBAExcel用VBA连续重命名工作表
【发布时间】:2016-12-14 12:58:23
【问题描述】:

我正在使用下面的代码复制我的 Excel 表格(它会弹出一个框询问用户他们想要复制表格多少次)

Sub Create()
'Updateby Extendoffice 20160704
    Dim I As Long
    Dim xNumber As Integer
    Dim xName As String
    Dim xActiveSheet As Worksheet
    On Error Resume Next
    Application.ScreenUpdating = False
    Set xActiveSheet = ActiveSheet
    xNumber = InputBox("Enter number of times to duplicate this sheet")
    For I = 1 To xNumber
        xName = ActiveSheet.Name
        xActiveSheet.Copy After:=ActiveWorkbook.Sheets(xName)
        ActiveSheet.Name = "dd-mm-yy" & I
    Next
    xActiveSheet.Activate
    Application.ScreenUpdating = True
End Sub

我希望 excel VBA 连续重命名工作表

要复制的工作表将始终是月初“01-01-17”,我希望相应地重命名每个工作表,“02-01-17、03-01-17 等”

【问题讨论】:

    标签: vba excel excel-formula


    【解决方案1】:

    MSDN DateSerial Function (Visual Basic):返回代表指定年月日的 Date 值,时间信息设置为午夜 (00:00:00)。

    ActiveSheet.Name = Format(DateSerial(2017,I,1), "dd-mm-yy")
    

    【讨论】:

      猜你喜欢
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-29
      • 1970-01-01
      相关资源
      最近更新 更多