+ Reply to Thread
Results 1 to 6 of 6

Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

  1. #1
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Question Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    Hi all,

    I would like to import data from a closed Excel spreadsheet (.xls, .xlsm or .xlsx) on click into a worksheet called "LOCFile".
    On click of the button, it should ask for the file to import from and from which tab/worksheet in the source file (the source file might have multiple worksheets that might differ from file to file so ideally it should ask for the correct worksheet). The data should be copied/imported 1 to 1 and ideally in the source formatting (the file will contain translations so there will be a lot of special characters which should stay the same when copied over).

    I've tried several scripts I found online now, but every script is only doing a part of the job (e.g. you can't select which file to import from, it defaults to importing the first worksheet it can find in the locfile, it does not keep source formatting etc.) so quite helpless here :-(

    This is a script I found which seems to be working to a certain extend, however, it simply copies the whole workbook (not the content) and adds a new worksheet to the file instead of importing to an existing worksheet.

    Quite a noob when it comes to VBA and still learning so any help would be appreciated

    Many thanks!

    Please Login or Register  to view this content.
    Last edited by kingofcamden; 09-25-2018 at 10:35 AM. Reason: Solved.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    Try this. Set the destination worksheet to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Thumbs up Re: Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    Hi Alphafrog,

    WOW! I'm impressed!! Did you just code that from scratch? This is simply amazing!! Thank you so much.

    Is there any chance to:
    • jump back to the worksheet the button is on once the import is finished? Ideally I would put the LOCfile worksheet (that now contains the loaded data) on hide.
    • can a message appear "Import completed" once the import is finished?

    Other than that, this is EXACTLY what I was looking for
    Cheers!

  4. #4
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    I managed to get the 'import completed' message to show up - wohoo!

    Please Login or Register  to view this content.
    Also added
    Please Login or Register  to view this content.
    at the end of the sub to go back to the initial worksheet. Seems to do the trick!

    Thanks again for your help
    Last edited by kingofcamden; 09-25-2018 at 10:34 AM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    You're welcome. Thanks for the feedback.

    Delete the red line and it will stay on the original worksheet.

    Add the blue line for the message.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 09-25-2018 at 07:16 PM.

  6. #6
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Excel VBA Button: Import Data from other worksheet incl. selection of source worksheet

    Hi Alphafrog,

    Ace! Thanks so much!

+ 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. Replies: 2
    Last Post: 09-28-2016, 02:09 PM
  2. [SOLVED] Match Drop Down List Selection and Import from worksheet
    By sandy1977 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 08:09 PM
  3. Replies: 5
    Last Post: 07-17-2012, 01:34 AM
  4. Macro to import an excel worksheet into a specific worksheet.
    By Bisboy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2010, 10:22 AM
  5. [SOLVED] import worksheet based on a selection
    By John Casteel in forum Excel General
    Replies: 0
    Last Post: 06-15-2006, 01:55 AM
  6. Replies: 3
    Last Post: 12-27-2005, 01:55 PM
  7. Replies: 1
    Last Post: 05-09-2005, 02:06 PM

Tags for this Thread

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