+ Reply to Thread
Results 1 to 5 of 5

Code to import worksheet using dialogue box

  1. #1
    Registered User
    Join Date
    09-05-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    14

    Code to import worksheet using dialogue box

    Hi there,

    I'm looking for some code that will import an Excel worksheet that has been exported from a DB. Essentially, the macro should do the following upon execution:

    1. Display file-open dialogue box to allow selection of a single file
    2. Copy worksheet from within selected workbook ' there will only ever be one worksheet in workbook and will always be called "Sheet 1", as per how the exporting DB operates
    3. Close imported file '' it would be beneficial if user doesn't actually see the open/closing to give a smoother UEX
    4. Name "Sheet 1" as x


    I then have subsequent macros to derive values, format, prepare for publication etc.


    Any help would be most appreciated!



    Thanks,

    Rob.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Code to import worksheet using dialogue box

    Hello and welcome to the forum.

    Where does the data from the sheet you're copying end up in the destination file?
    a) In a pre-existing worksheet, and if so what about any data already there. Should that be removed first.
    b) As a completely new sheet called 'x'?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-05-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    14

    Re: Code to import worksheet using dialogue box

    Sorry, meant to provide that detail. It should be pasted as the last sheet in the workbook that the macro is being executed.

    Original sheet should not be removed.

    Copied and pasted as a whole sheet, so effectively a new sheet in the existing workbook from where the macro has been executed.



    Rob.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Code to import worksheet using dialogue box

    .
    .
    Try this code :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-05-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    14

    Re: Code to import worksheet using dialogue box

    Thanks. That was really useful.

    Would you be able to show me how to do "inverse", i.e:

    1. Open dialogue box
    2. Set save path and filename
    3. Move selected worksheet to new file
    4. Save file as filename and to path defined in step 2
    5. Close saved file
    6. Confirm export to user


    Rob.

+ 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. how to import html code with no name into worksheet cell?
    By Ja Zee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2015, 07:12 PM
  2. [SOLVED] Pesky dialogue box keeps VBA code from running smooth...
    By Christopher76 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-03-2013, 10:39 AM
  3. [SOLVED] Import multiple CVSs to one worksheet - Modify VBA code
    By EIKA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-24-2013, 05:57 PM
  4. [SOLVED] The Print dialogue interferes with the following Macro code
    By Jongering in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2012, 06:53 AM
  5. Dialogue box to select folder >files for import?
    By firebladejr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2008, 08:38 AM
  6. dialogue box breaking loop code
    By Aussie_Striker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2007, 01:51 AM
  7. code for print dialogue
    By BorisS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2006, 07:25 AM

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