+ Reply to Thread
Results 1 to 6 of 6

Macro to copy data from other workbook - let user choose which open workbook

  1. #1
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Macro to copy data from other workbook - let user choose which open workbook

    Hi there,

    I receive sale handover workbooks from Sales on a daily / weekly basis, using a set template. I have a central workbook which is used to track these as they come in, recording things like client name, value etc.

    I am building a macro to automatically import these kinds of details from each handover workbook into the central tracking workbook.. I need the macro to present the user with a list of all open workbooks, then allow the user to choose which open workbook they want to copy data from.

    I can see how to obtain the name of the current open workbook, or how to select a workbook using a file>open type dialog, but that would cause problems when the workbookyou want is stored in a Lotus Notes or SharePoint database. Hence my desire to have the user open the handover workbook first, then run the macro from the tracking workbook to choose which of the other open workbooks to copy data from.

    Any thoughts, please?
    Thanks!

    ssu95bm
    Last edited by ssu95bm; 01-12-2011 at 11:19 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,236

    Re: Macro to copy data from other workbook - let user choose which open workbook

    Hi ssu95bm and welcome to the forum,

    How you want to present the open workbooks and have your users select one is my question. To find all open workbooks you can use the index method shown in the example on:
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=443

    The example above asks for a specific workbook name by going through all opened workbooks. You can change the code a bit to list all open workbooks.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Macro to copy data from other workbook - let user choose which open workbook

    Hi MarvinP,

    Thanks - I will check out the example!

    ssu95bm

  4. #4
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Macro to copy data from other workbook - let user choose which open workbook

    Hi MarvinP, and everyone,

    Thanks for the example. I have adapted it to produce a list of open workbooks:

    Please Login or Register  to view this content.

    The next bit is how do I turn this into an option list, for a user to select one of?

    Thanks!
    ssu95bm

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,236

    Re: Macro to copy data from other workbook - let user choose which open workbook

    Hi,

    I'd put the list on the sheet in cells and then do a validation list from it.

    I have no idea how your user interface works but validation lists are a lot easier than building userforms.

  6. #6
    Registered User
    Join Date
    01-10-2011
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Macro to copy data from other workbook - let user choose which open workbook

    Hi MarvinP,

    Many thanks. I have put the open file names onto a worksheet, then used an input prompt to get the user to select one.

    With some help from a colleague at this end, however, I built a simple form with one combobox and an ok button. The code below populates the combobox (named "ComboBox1", then calls the form "UserForm1" which has the combo box. When the form is closed the value in the combo box is returned to me.

    Please Login or Register  to view this content.

    Many thanks again!
    ssu95bm

+ 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