Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2005
    Location
    Asia Pacific, Bangkok Metropolis
    Posts
    378
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add a sheet in the Active Workbook (Excel 2003)

    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,
    Hope this is helpful

    francis, <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    My Reading

    Pivot Table 101
    Pivot Table
    Array

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add a sheet in the Active Workbook (Excel 2003)

    Does this do what you want?

    With ActiveWorkbook.Worksheets
    .Add.Name = "Product"
    .Add.Name = "Code"
    .Add.Name = "Mode"
    End With

  3. #3
    Lounger
    Join Date
    Sep 2008
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add a sheet in the Active Workbook (Excel 2003

    If you run this code

    <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</code>

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •