复制隐藏的主表,将其重命名并将其放置在工作簿的末尾 [英] Copy hidden Master sheet rename it and place it at end of workbook
问题描述
我正在尝试复制一个名为Master的隐藏页面.
I'm trying to copy a hidden page named Master.
当用户单击名为开始"的工作表中的按钮时,它将打开一个输入框.用户将输入新的工作表名称.新工作表将放置在名为start的工作表之后.用户可以根据需要输入任意张纸,每张纸放在最后.如果单击取消,则输入框需要对无效条目和结束金额进行错误检查.
When the user clicks a button in a sheet named start it will open an input box. The user will input the new sheet name. The new sheet will be placed after the sheet named start. The user can enter as many sheets as needed with each one being placed at the end. The input box need to have an error check for invalid entries and end sum if the cancel is clicked.
下面是我所拥有的.它只是在开始后重命名工作表.它不会使用新名称创建新工作表.
Below is what I have. It just renames the sheet after the start. It is not creating a new sheet with the new name.
Sub Button3_Click()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet: Set ws = wb.Sheets("Master")
Dim newws As Worksheet, sh As Worksheet, newname
Dim query As Long, xst As Boolean, info As String
retry:
xst = False
newname = Application.InputBox("Enter Inmate Name and Number.", info, , , , , , 2)
If newname = "False" Then Exit Sub
For Each sh In wb.Sheets
If sh.Name = newname Then
xst = True: Exit For
End If
Next
If Len(newname) = 0 Or xst = True Then
info = "Sheet name is invalid. Please retry."
GoTo retry
End If
ws.Copy after:=ws
Set newws = ActiveSheet: newws.Name = sh
End Sub
推荐答案
更改最后三个.
Application.ScreenUpdating = false
ws.visible = xlSheetVisible
ws.Copy after:=ws
Set newws = ActiveSheet: newws.Name = sh
ws.visible = xlsheethidden
Application.ScreenUpdating = True
End Sub
这篇关于复制隐藏的主表,将其重命名并将其放置在工作簿的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!