+ Reply to Thread
Results 1 to 7 of 7

Opening only xlsx files

  1. #1
    Registered User
    Join Date
    01-04-2012
    Location
    Derby, England
    MS-Off Ver
    2010, 2013 2016 Pro
    Posts
    85

    Opening only xlsx files

    Hi All,

    My current code will open and compile all my required cells to a Master document and all works fine until I come across another file type, my problem is I need to only open files of a xlsx type, my current code will try to open any file beginning with PJ, even a doc file, how can I alter to code to only open xlsx files?

    Please Login or Register  to view this content.
    Last edited by RoyLittle0; 04-21-2014 at 12:49 PM. Reason: Corrected Code Tags and Full code added

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Opening only xlsx files

    Hi Roy

    This is Code I use
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening only xlsx files

    Hello RoyLittle0,

    You should always post the complete Sub or Function code. It can then be easily copied to a workbook and examined for errors, tested, etc.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    01-04-2012
    Location
    Derby, England
    MS-Off Ver
    2010, 2013 2016 Pro
    Posts
    85

    Re: Opening only xlsx files

    Thanks, I have added the full code, so that you can see what I am trying to do, I can open all files beginning with PJ, but unfortunately there are some .docx files also beginning with PJ within the folders which throws up an error, I have many xlsx files in the folder but I only want to read the ones beginning with PJ

    Regards
    Roy

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening only xlsx files

    Hello RoyLittle0,


    Thanks for filling the code. It makes a big difference in what you want to do.

    Do You need to check all subfolders as well or just a certain depth of subfolders, like the only folders in the main folder?

  6. #6
    Registered User
    Join Date
    01-04-2012
    Location
    Derby, England
    MS-Off Ver
    2010, 2013 2016 Pro
    Posts
    85

    Re: Opening only xlsx files

    Hi Leith

    Yes I need to check all sub-folders, there will be nothing in the main folder with the exception of sub-folders, but the sub-folders could be 6 deep in places but at least 5 folders to search

    I thing the folder structure is something like this.
    Main Folder - Country/Sales Support Unit - Company - Year - Machine Type
    Last edited by RoyLittle0; 04-21-2014 at 01:58 PM.

  7. #7
    Registered User
    Join Date
    01-04-2012
    Location
    Derby, England
    MS-Off Ver
    2010, 2013 2016 Pro
    Posts
    85

    Re: Opening only xlsx files

    Also, is it possible to copy the file location into the Master sheet so I can use it as a hyperlink ?

+ 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: 3
    Last Post: 01-05-2014, 05:50 AM
  2. Replies: 0
    Last Post: 03-13-2013, 09:08 PM
  3. How to automatically get values from one .xlsx to another without opening files?
    By kummakki in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 12:44 PM
  4. Merge Data from different .xlsx files & different sheet to a new .xlsx
    By QcSylvanio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-03-2012, 01:11 PM
  5. How to add the columns data of several xlsx files of a folder in another xlsx file
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-25-2012, 04:29 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