+ Reply to Thread
Results 1 to 2 of 2

create a copy of a sheet and insert it into the same workbook.

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    create a copy of a sheet and insert it into the same workbook.

    This is a piece of code I Got.

    For Each sh In ActiveWorkbook.Sheets
    ' below to check if there is a worksheet with the name locally stored data and if there is one then delet

    If sh.Name = "Locally Stored Data" Then
    Application.DisplayAlerts = False
    sh.Delete
    Application.DisplayAlerts = True
    End If
    Next sh

    ' copys a templatte sheet and then rename it and copy data etc.

    Sheets("Temp").Visible = True
    Sheets("Temp").Select
    ActiveSheet.Copy
    ActiveSheet.Name = "Locally Stored Data"
    Sheets("Temp").Visible = False
    Sheets("Data").Visible = True
    Range("A9").Select
    Selection.CurrentRegion.Select
    Selection.Copy
    Sheets("Locally Stored Data").Select
    Range("A2").Select


    It gets to the highlighted part and then copys the Sheet temp into a new workbook instead of keeping it in the same workbook. any ideas?

  2. #2
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    I would try two things:

    replace your code with:
    Sheets("Temp").Copy Before:=Sheets("Temp")

    or in stead of a not visible sheet
    insert a template sheet:

    Sheets.Add Type:= "C:\Template.xlt"

    the last way is the better way I think

+ 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