Find new page in excel vba

In Excel VBA, you can create a new page (also known as a new worksheet) using the following methods:

Method 1: Using the Worksheets.Add method

You can use the Worksheets.Add method to create a new worksheet. Here's an example:

Sub CreateNewWorksheet()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets.Add
    ws.Name = "New Worksheet"
End Sub

This code creates a new worksheet and names it "New Worksheet".

Method 2: Using the Sheets.Add method

You can also use the Sheets.Add method to create a new worksheet. Here's an example:

Sub CreateNewWorksheet()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets.Add
    ws.Name = "New Worksheet"
End Sub

This code is similar to the previous example, but uses the Sheets.Add method instead.

Method 3: Using the Application.Workbooks.Add method

You can also use the Application.Workbooks.Add method to create a new workbook and add a new worksheet to it. Here's an example:

Sub CreateNewWorksheet()
    Dim wb As Workbook
    Set wb = Application.Workbooks.Add
    Dim ws As Worksheet
    Set ws = wb.Sheets(1)
    ws.Name = "New Worksheet"
End Sub

This code creates a new workbook, adds a new worksheet to it, and names the worksheet "New Worksheet".

Tips