|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub CopyActiveSheetAndRename()
Dim xStr As String
Dim newSheet As Worksheet
Dim dateStr As String
dateStr = InputBox("请输入工作表的日期(格式为月.日):", "输入日期")
If dateStr = "" Then
Exit Sub
End If
Set newSheet = ActiveSheet.Copy(After:=Sheets(Sheets.Count))
Retry:
Err.Clear
xStr = InputBox("请输入工作表的新名称(格式为月.日):" _
, "重命名工作表", dateStr)
If xStr = "" Then
Exit Sub
End If
On Error Resume Next
newSheet.Name = xStr
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description
Err.Clear
GoTo Retry
End If
On Error GoTo 0
newSheet.Range("B5:B10,B12:B21,B24").ClearContents
newSheet.Range("C5").Value = _
Sheets(Replace(xStr, ".", ".") - 1).Range("C5").Value + newSheet.Range("B5").Value
newSheet.Range("B26").Value = Sheets(Replace(xStr, ".", ".") - 1).Range("B30").Value
newSheet.Range("B27").Value = Sheets(Replace(xStr, ".", ".") - 1).Range("B31").Value
End Sub
|
评分
-
1
查看全部评分
-
|