如何在Excel中使用Vba创建新工作表 [英] How Do I Create A New Sheet Using Vba In Excel
本文介绍了如何在Excel中使用Vba创建新工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问我一直在使用excel工作簿中的VBA创建一个新工作表..请帮助我,因为我有脚本来做到这一点,但不知道如何通过它。
Please I have been working on creating a new sheet using VBA in excel workbook.. please kindly help as i have the script to do that but doesnt know how to work through it.
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sub TestSheetCreate()
Dim mySheetName As String, mySheetNameTest As String
mySheetName = "Sheet7"
On Error Resume Next
mySheetNameTest = Worksheets(mySheetName).Name
If Err.Number = 0 Then
MsgBox "The sheet named ''" & mySheetName & "'' DOES exist in this workbook."
Else
Err.Clear
Worksheets.Add.Name = mySheetName
MsgBox "The sheet named ''" & mySheetName & "'' did not exist in this workbook but it has been created now."
End If
End Sub
推荐答案
这篇关于如何在Excel中使用Vba创建新工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文