+ Reply to Thread
Results 1 to 6 of 6

open folder and execute code for xls files except 1 file

  1. #1
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    open folder and execute code for xls files except 1 file

    Hi All,

    I have a folder that contains many xlsx files
    in this folder there is an Excel workbook with name Host.xlsx

    This excel workbook has a button that contains my macro. ok ? you are with me ..?

    What I want is

    when I press this button in host.xlsx file
    it opens all excel workbooks in that folder and execute my macro code then open next workbook and execute my macro and so on......

    You will find 3 files ( host sheet, sheet1 and sheet2 )
    when I press fill in button in host sheet:

    it will copy the data from sheet1 in tab inv_oracle and paste it into host sheet in tab host
    and then copy the data from sheet2 in tab inv_oracle and paste it into host sheet in tab host after the last record inserted before



    - macro scenario is to copy data from these workbooks -with specific sheet inv_oracle - and paste it into host.xlsx -
    Kindly check the attached file ,tab to be like this to understand my point of view

    my code is working but in the same excel workbook I don't know how to amend it to work for mutiple files

    Thanks for your help
    Regards
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,946

    Re: open folder and execute code for xls files except 1 file

    Put this in the same folder as your other files...
    host sheet.xlsm
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: open folder and execute code for xls files except 1 file

    Hi,

    I have encountered this issue

    Regards

  4. #4
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: open folder and execute code for xls files except 1 file

    find attached picture
    Thanks
    Attached Images Attached Images

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,946

    Re: open folder and execute code for xls files except 1 file

    The active folder must have changed so the file is not being found, so change the line

    Set wkbk = Workbooks.Open(strFN)

    to

    Set wkbk = Workbooks.Open(ThisWorkbook.Path & "\" & strFN)

  6. #6
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: open folder and execute code for xls files except 1 file

    Thanks a lot man
    It works
    I don't know how to thanks you

+ 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. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. Replies: 2
    Last Post: 02-10-2014, 11:52 AM
  3. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  4. VBA code to open and execute files from different directories in Command window
    By AlexXYZ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2012, 01:49 PM
  5. VBA code to open and execute files from different directories in Commend window
    By AlexXYZ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2012, 01:52 AM

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