+ Reply to Thread
Results 1 to 2 of 2

Copy a worksheet from one file to another

Hybrid View

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    8

    Copy a worksheet from one file to another

    I'm looking for a way to copy a complete worksheet from one file to an open file.

    My first thought was to open the source file, find the data limits, build an index to capture the data.
    Then clear the destination worksheet and loop through the index writting the data.

    Then I thought I might have trouble getting the equations instead of the values.
    So I thought I would look for a way to copy the entire worksheet from one file to another.

    I have seen and tried yudlugar's code from "Copy data from another worksheet without open that workbook".
    http://www.excelforum.com/excel-prog...-workbook.html

    It may be helpfull but I think I'll still miss out on the equations, I don't like all the zeros I get for empty fields and I don't know the limits of the source file.
    I might be able to get it to work but I thought it would be eaisier to delete a worksheet and replace it with a new one.

    Does anyone have any ideas?

  2. #2
    Registered User
    Join Date
    06-26-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Copy a worksheet from one file to another

    I think I'm headed in the right direction.

    Sub Consolidate()
    Dim ws1 As Worksheet 'worksheet to be copied
    Dim ws2 As Worksheet 'the copy

    Dim wbk As Workbook

    Sheets("toledo").Delete

    Set wbk = Workbooks.Open("C:\Users\strohtm\Documents\Projects\Rebuild Schedule\Toledo Schedule x9.xlsm")
    Set ws1 = wbk.Sheets("summary")

    Set ws2 = ThisWorkbook.ActiveSheet


    ws1.Copy after:=ws2
    wbk.Close True
    Sheets("summary").Select
    Set ws2 = ThisWorkbook.ActiveSheet
    ws2.Name = "Toledo"

    End Sub

+ 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