excel用宏建立工作表

发布网友 发布时间:2022-04-23 04:46

我来回答

4个回答

热心网友 时间:2023-09-06 12:52

Sub test()
Dim ipath$, iname$
Application.DisplayAlerts = False
With ThisWorkbook
ipath = .Path
iname = Left(.Name, InStr(.Name, ".") - 1)
.SaveAs ipath & iname & Format(Date, "mm月dd日") & ".xlsx"
End With
Workbooks.Open (ipath & iname & Format(Date, "mm月dd日") & ".xlsx")
With ActiveWorkbook
.Sheets(1).Range("a2") = iname
.Save
.Close
End With
Application.DisplayAlerts = True
End Sub
这样应该OK了!追问理解错误

热心网友 时间:2023-09-06 12:52

1、以建立副本的形式,在当前工作簿中建立名称为“xxx+当前日期(月和日)”的工作表

Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Sheets(sheets.count)
sheets(sheets.count).name="xxx" & date

2.把A2单元格的内容改为xxx,格式不变
range("a2")=xxx

热心网友 时间:2023-09-06 12:53

在sheet3下插入下面的代码:
' ***********************************************
Private Sub Worksheet_Activate()
Macro1
End Sub
' ***********************************************
模块下代码如下:
Sub Macro1()
N = 0
For Each MY In Worksheets
N = N + 1
If MY.Name = ActiveSheet.Name Then
Exit For
End If
Next
If N = Worksheets.Count Then
ActiveSheet.Select
Name = ActiveSheet.Name
ActiveSheet.Copy Before:=ActiveSheet
ActiveSheet.Select
ActiveSheet.Name = "Sheet" & N + 1
ActiveSheet.Move After:=Sheets(Name)
Sheets(Name).Select
Else
'do nothing
End If
End Sub

热心网友 时间:2023-09-06 12:53

Dim shet1 As Worksheet
Set shet1 = ThisWorkbook.Sheets.Add
shet1.Name = "名字"

以上名字你自己取

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com