+ Reply to Thread
Results 1 to 1 of 1

Macro to import an excel worksheet into a specific worksheet.

Hybrid View

  1. #1
    Registered User
    Join Date
    12-06-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question Macro to import an excel worksheet into a specific worksheet.

    Hi,

    Im needing help on macro which imports a worksheet(s) into the open workbook's specific worksheet(s).

    We have a shared drive with the files in one folder I want to import from. When I run the macro i want them to drop into specific worksheet(s), i.e refreshing the workbook
    So far i have this:

    Sub GetFile()
    ' This macro will import a file into this workbook
     Sheets("Menu").Select
        PathName = Range("D2").Value
        Filename = Range("D3").Value
        TabName = Range("D4").Value
        ControlFile = ActiveWorkbook.Name
        Workbooks.Open Filename:=PathName & Filename
        ActiveSheet.Name = TabName
        Sheets(TabName).Copy after:=Workbooks(ControlFile).Sheets(1)
        Windows(Filename).Activate
        ActiveWorkbook.Close SaveChanges:=False
        Windows(ControlFile).Activate
        Sheets("Menu").Select
        Range("D8").Select
        ActiveCell.Value = "Completed"
        Range("D9").Select
    End Sub
    But it just creates new worksheet with the name in "D4" not copy into Tabname "D4".

    Any help would be really appreciated, im just starting out on macro's.
    Last edited by pike; 12-08-2010 at 01:45 AM. Reason: add code tags for newbie

+ 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