+ Reply to Thread
Results 1 to 4 of 4

Help importing files of specific types

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Help importing files of specific types

    I have the code below which imports all filetype .MOV files into the sheet. I would like to extend this to include other filetypes from a list of filetypes this could be any number from 2 upwards, presumably I would also have to cover the fact that some might be upper case and some lower

    The only way I know how to do it would be to count the number of lines in the list then make the variable 'suffix' equal each one in turn in both upper and lower case then run through the code below for each one. No doubt this would work but it seems an inefficient way of doing it.

    Can you suggest a better way?

    Please Login or Register  to view this content.
    Last edited by tryer; 11-20-2012 at 04:21 AM.

  2. #2
    Registered User
    Join Date
    11-19-2012
    Location
    Wilmington Delaware
    MS-Off Ver
    Excel 2003 2007 2010
    Posts
    23

    Re: Help importing files of specific types

    Just some suggestions:

    Read the list of filetypes into an array. As you know the first cell that has a value, then test to see if the next cell below has an entry. If so, then expand the array, redim preserve MyArray(1 to N) for example, when N is your counter and set the value of the Nth entry to the cell's value. Once you have the array filled, you can then test to see if the right most characters are equal to the array:

    bfound = false
    For I = 1 to N
    if right(strfile, len(MyArray(i)) = myarray(i) then
    bfound = true
    exit for
    next

    If bfound is true then you perform the action you want.

    Put the following at the top of your module

    Option Compare Text

    This eliminates case comparison issue.

    Robert Flanagan
    Add-ins.com LLC
    http://www.add-ins.com
    Productivity add-ins and downloadable books on VB macros for Excel

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Help importing files of specific types

    thanks to bob
    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  4. #4
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: Help importing files of specific types

    Thank you both, I will experiment with this and let you know how i get on

+ 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