How to Create a Sheet if Not Exist in the Workbook

This tutorial is for you if you use Excel and want to automate chores or improve workflow. Sometimes manually determining whether a specific sheet already exists and then creating it if not might be time-consuming when working with large workbooks or complicated projects. Thankfully, Excel comes with strong capabilities that let us automate these processes with a minimal amount of code.

In this article, we'll go through how to add a new sheet to an Excel workbook only if there isn't one there already. We'll be utilising the programming language Visual Basic for Applications (VBA), which was created especially for automating Excel processes. By the end of this process, you'll be able to write VBA code to determine whether a sheet already exists in a workbook and, if not, to create one. You will be able to automate repetitive operations, save time, and increase your productivity when using Excel as a result of this knowledge. So let's get started and discover how to create a sheet in an Excel workbook if one does not already exist!

Create a Sheet If Not Exist in the Workbook

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to know how you can create a sheet if one does not exist in the workbook in Excel

Step 1

Consider any Excel.

First use Alt + F11 to open the VBA application.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.


Sub TestSheetCreate()
   Dim newSheetName As String
   Dim checkSheetName As String
   newSheetName = Application.InputBox("Input Sheet Name:", "Create Sheet Not", 
   _"sheet4", , , , , 2)
   On Error Resume Next
   checkSheetName = Worksheets(newSheetName).Name
   If checkSheetName = "" Then
      Worksheets.Add.Name = newSheetName
      MsgBox "The sheet named ''" & newSheetName & _
      "'' does not exist in this workbook.", _
      vbInformation, "Create Sheet Not Exists"
      MsgBox "The sheet named ''" & newSheetName & _
      "''Exist in this workbook.", vbInformation, "Create Sheet Not Exists"
   End If
End Sub

Step 3

Then click F5 to run the module, enter the sheet name, and click Ok to complete the task.

F5 > Sheet Name > Ok.

Then you can see the confirmation.


In this tutorial, we have used a simple example to demonstrate how you can create a sheet if one does not exist in the workbook in Excel to highlight a particular set of data.

Updated on: 12-Jul-2023


Kickstart Your Career

Get certified by completing the course

Get Started