• Add a sheet in the Active Workbook (Excel 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Add a sheet in the Active Workbook (Excel 2003)

    Author
    Topic
    #453923

    Hi all
    The subject mentioned seem to be easy. However, I have this macro which will add a new workbook with Sheet1.
    Due to all my other macro are in this workbook, I need to change the following line to add a new sheet and the others sheets
    in the existing workbook.

    Set BaseWks = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
    BaseWks.Parent.Worksheets.Add.Name = “Product”
    BaseWks.Parent.Worksheets.Add.Name = “Code”
    BaseWks.Parent.Worksheets.Add.Name = “Mode”

    How do I change these lines?

    Thanks

    regards,

    Viewing 0 reply threads
    Author
    Replies
    • #1125519

      Does this do what you want?

      With ActiveWorkbook.Worksheets
      .Add.Name = “Product”
      .Add.Name = “Code”
      .Add.Name = “Mode”
      End With

      • #1125532

        If you run this code

        Dim newWorkbook As Workbook, myFullFile As String

        myFullFile = Application.GetOpenFilename

        If myFullFile = "False" Then
        Exit Sub: Rem Cancel pressed
        Else
        Set newWorkbook = Application.Workbooks.Add(myFullFile)
        End If

        It will prompt you to select a file and will create a duplicate of that file.

    Viewing 0 reply threads
    Reply To: Add a sheet in the Active Workbook (Excel 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: