+ Reply to Thread
Results 1 to 8 of 8

is there anyway to create a clone of an excel sheet in vba?

  1. #1
    Daniel
    Guest

    is there anyway to create a clone of an excel sheet in vba?

    is there anyway to create a clone of an excel sheet in vba?



  2. #2
    Norman Jones
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    Hi Daniel,

    To add a copy in the same workbook, try:

    Sub Tester
    With ActiveWorkbook
    .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    End With
    End Sub

    To create a new single-sheet workbook containing a copy of the sheet, try:

    Sub Tester2
    ActiveWorkbook.Sheets("MySheet").copy
    End sub

    ---
    Regards,
    Norman



    "Daniel" <[email protected]> wrote in message
    news:[email protected]...
    > is there anyway to create a clone of an excel sheet in vba?
    >
    >




  3. #3
    Robin Hammond
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    Daniel,

    Norman is right as usual, but just in case you meant workbook rather than
    worksheet, have a look at the SaveCopyAs method in the vba help file.

    Robin Hammond
    www.enhanceddatasystems.com

    "Norman Jones" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi Daniel,
    >
    > To add a copy in the same workbook, try:
    >
    > Sub Tester
    > With ActiveWorkbook
    > .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    > End With
    > End Sub
    >
    > To create a new single-sheet workbook containing a copy of the sheet, try:
    >
    > Sub Tester2
    > ActiveWorkbook.Sheets("MySheet").copy
    > End sub
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Daniel" <[email protected]> wrote in message
    > news:[email protected]...
    >> is there anyway to create a clone of an excel sheet in vba?
    >>
    >>

    >
    >




  4. #4
    Dave Peterson
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    Just a typo that won't matter if it's running against the activeworkbook, but
    could matter if the workbook isn't active...

    Sub Tester
    With ActiveWorkbook
    .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    End With
    End Sub

    is missing a dot in front of sheets.count.

    Sub Tester
    With ActiveWorkbook
    .Sheets("MySheet").Copy After:=.Sheets(.Sheets.Count)
    End With
    End Sub

    Norman Jones wrote:
    >
    > Hi Daniel,
    >
    > To add a copy in the same workbook, try:
    >
    > Sub Tester
    > With ActiveWorkbook
    > .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    > End With
    > End Sub
    >
    > To create a new single-sheet workbook containing a copy of the sheet, try:
    >
    > Sub Tester2
    > ActiveWorkbook.Sheets("MySheet").copy
    > End sub
    >
    > ---
    > Regards,
    > Norman
    >
    > "Daniel" <[email protected]> wrote in message
    > news:[email protected]...
    > > is there anyway to create a clone of an excel sheet in vba?
    > >
    > >


    --

    Dave Peterson

  5. #5
    Norman Jones
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    Hi Dave,

    Thank you!

    ---
    Regards,
    Norman



    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Just a typo that won't matter if it's running against the activeworkbook,
    > but
    > could matter if the workbook isn't active...
    >
    > Sub Tester
    > With ActiveWorkbook
    > .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    > End With
    > End Sub
    >
    > is missing a dot in front of sheets.count.
    >
    > Sub Tester
    > With ActiveWorkbook
    > .Sheets("MySheet").Copy After:=.Sheets(.Sheets.Count)
    > End With
    > End Sub
    >
    > Norman Jones wrote:
    >>
    >> Hi Daniel,
    >>
    >> To add a copy in the same workbook, try:
    >>
    >> Sub Tester
    >> With ActiveWorkbook
    >> .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    >> End With
    >> End Sub
    >>
    >> To create a new single-sheet workbook containing a copy of the sheet,
    >> try:
    >>
    >> Sub Tester2
    >> ActiveWorkbook.Sheets("MySheet").copy
    >> End sub
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >> "Daniel" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > is there anyway to create a clone of an excel sheet in vba?
    >> >
    >> >

    >
    > --
    >
    > Dave Peterson




  6. #6
    Daniel
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference to
    the newly created copy of this sheet?

    "Norman Jones" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi Daniel,
    >
    > To add a copy in the same workbook, try:
    >
    > Sub Tester
    > With ActiveWorkbook
    > .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    > End With
    > End Sub
    >
    > To create a new single-sheet workbook containing a copy of the sheet, try:
    >
    > Sub Tester2
    > ActiveWorkbook.Sheets("MySheet").copy
    > End sub
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Daniel" <[email protected]> wrote in message
    > news:[email protected]...
    > > is there anyway to create a clone of an excel sheet in vba?
    > >
    > >

    >
    >




  7. #7
    Dave Peterson
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    You have this at your other post:

    dim newWks as worksheet

    with activeworkbook
    .sheets("mysheet).copy _
    before:=.sheets(1)
    end with
    set newwks = activesheet
    newwks.name = "this is a new sheet!"

    (the activesheet is the one that just got created.)

    Daniel wrote:
    >
    > in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference to
    > the newly created copy of this sheet?
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:%[email protected]...
    > > Hi Daniel,
    > >
    > > To add a copy in the same workbook, try:
    > >
    > > Sub Tester
    > > With ActiveWorkbook
    > > .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    > > End With
    > > End Sub
    > >
    > > To create a new single-sheet workbook containing a copy of the sheet, try:
    > >
    > > Sub Tester2
    > > ActiveWorkbook.Sheets("MySheet").copy
    > > End sub
    > >
    > > ---
    > > Regards,
    > > Norman
    > >
    > >
    > >
    > > "Daniel" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > is there anyway to create a clone of an excel sheet in vba?
    > > >
    > > >

    > >
    > >


    --

    Dave Peterson

  8. #8
    Norman Jones
    Guest

    Re: is there anyway to create a clone of an excel sheet in vba?

    Hi Daniel,

    Try something like:

    Dim WB As Workbook
    Dim WS As Worksheet

    Set WB = ActiveWorkbook
    With WB
    .Sheets("Mysheet").Copy Before:=.Sheets(1)
    End With

    Set WS = ActiveSheet

    ---
    Regards,
    Norman



    "Daniel" <[email protected]> wrote in message
    news:[email protected]...
    > in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference
    > to
    > the newly created copy of this sheet?
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:%[email protected]...
    >> Hi Daniel,
    >>
    >> To add a copy in the same workbook, try:
    >>
    >> Sub Tester
    >> With ActiveWorkbook
    >> .Sheets("MySheet").Copy After:=.Sheets(Sheets.Count)
    >> End With
    >> End Sub
    >>
    >> To create a new single-sheet workbook containing a copy of the sheet,
    >> try:
    >>
    >> Sub Tester2
    >> ActiveWorkbook.Sheets("MySheet").copy
    >> End sub
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >>
    >> "Daniel" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > is there anyway to create a clone of an excel sheet in vba?
    >> >
    >> >

    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1