+ Reply to Thread
Results 1 to 2 of 2

VBA Macro - open and copy sheets from multiple files

  1. #1
    Registered User
    Join Date
    03-03-2019
    Location
    London
    MS-Off Ver
    2010
    Posts
    1

    VBA Macro - open and copy sheets from multiple files

    Hi, really hoping someone can assist.

    I have a file that I want to use a table of variables set out in columns A:D to find specific sheets in multiple workbooks and copy them across. I've tried multiple methods but the limits of my VBA knowledge are starting to show.

    In the columns I have,
    A a list of the files (filepaths+filenames) I want to open
    B the passwords to open those files
    C the filenames (i.e. in order to allow ability to select workbooks)
    D the sheet names that I want to select/copy across in the files

    So, I want the macro to start at A1, open that file using the password (B1), copy a specified sheet (D1) then loop down the list of files I have.

    Below is as far as I have got - it works, bit only if I include the workbook and worksheet name which will all be different when in use -


    ' Macro4 Macro
    '

    '
    Dim i As Integer

    i = 1

    Do While Cells(i, 1).Value <> ""

    Workbooks.Open Filename:=Cells(i, 2), Password:=Cells(i, 3)
    Sheets("ISC201802").Copy Before:=Workbooks("Cons File.xlsm").Sheets(1)
    Windows("IS Service Stability 2018 Opex IP3000 ISC201808.xlsx").Activate
    ActiveWindow.Close savechanges:=False
    ThisWorkbook.Activate
    Sheets("Sheet3").Activate

    i = i + 1

    Loop

    End Sub


    Any assistance would be very much appreciated,

    Many Thank,<

    Alex

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA Macro - open and copy sheets from multiple files

    try this

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

+ 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. macro to open files and copy specific sheet into new workbook (have open files part)
    By dangerdavedsp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2015, 02:23 PM
  2. [SOLVED] Macro to open multiple text files and perform operations in each one. Then copy results.
    By nihil666a in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-02-2014, 05:21 PM
  3. Problem of using VBA to open a list of files and copy to 2 sheets
    By garyyy3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2014, 09:40 PM
  4. Macro to open multiple files, remove header and save multiple files in a new format
    By twocircles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2014, 05:24 PM
  5. Replies: 0
    Last Post: 04-13-2013, 10:45 AM
  6. open files in folder and copy sheets to new workbook
    By matrix_xrs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 06:56 AM
  7. A Macro to open 2 linked files copy 3rd files Input sheet
    By barrha0b in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2010, 09:53 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