+ Reply to Thread
Results 1 to 9 of 9

Importing worksheet into my workbook

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Importing worksheet into my workbook

    I am using the (borrowed) code below to select and import a worksheet into my workbook.
    Please Login or Register  to view this content.
    Unfortunately it is failing in two places
    Please Login or Register  to view this content.
    I assume this is just colouring a tab so I have deleted this line but I can't get over this line
    Please Login or Register  to view this content.
    I think is is due maybe to conflicting worksheet names. Ideally I would like it to import all the data on the source worksheet into my own workbook sheet called say "Data". I think that maybe this isn't the right code as it is importing the worksheet and not just the contents of it. However that shouldn't be a problem as I can write code to copy the data from this imported sheet into the one I want then delete the redundant sheet but I still need to overcome the error on import.
    Any Idea's?
    Last edited by tryer; 10-20-2008 at 10:32 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Are you using a ListBox?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Roy,

    I have copied the code from the attached sheet which was posted on here some time ago. I found it does what I need in that it asks the user to browse for and select the source data.
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Change the import button code to this
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Thanks Roy, That works exactly as I wanted it to.

    You wouldn't believe how long I have been messing around with that code trying to make it work.
    Now trying to understand what you have done, In your line
    Please Login or Register  to view this content.
    I assume .usedrange.copy copies all the used cells from the the source worksheet, ThisWorkbook.Worksheets("Data").Cells selects the destination but I dont see any paste instruction? so then does putting the destination directly after the copy command cause the paste?

    sorry to be a pain but I'm trying to learn rather that just ask you guys to do my work for me

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Just a tip, if you highlight words like UsedRange in the VB Editor & press F! you will get hel on it.

    UsedRange is exactly what you think, the range that has been used on the sheet. The way that I wrote the copy specifies the destination.

  7. #7
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357
    Thank you

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    No problem, can you mark the thread solved

  9. #9
    Registered User
    Join Date
    08-22-2008
    Location
    Pelham AL
    Posts
    22

    Import a worksheet

    Hi Roy. I have been searching threads, because I am trying to figure out a way to import a worksheet from one workbook to another. I love the file that Tryer attached in one of the replies in this thread. I need something very similar to this, only I need to be able to specify both the worksheet to be copied AND the workbook to copy it to. Can you help?

    thanks
    marcia

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. copy entire worksheet to current workbook
    By AJHWilliams in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-16-2011, 08:47 PM
  2. Copy worksheet to another workbook
    By Lianne in forum Excel General
    Replies: 3
    Last Post: 08-29-2008, 09:36 PM
  3. Importing an excel worksheet
    By MasterMonk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-04-2008, 08:46 AM
  4. A button that opens a new workbook and saves the current worksheet on to it
    By shilpz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2008, 02:50 AM
  5. Worksheet # of ? in Workbook
    By CoastalMs in forum Excel General
    Replies: 3
    Last Post: 11-13-2007, 05:26 PM

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