+ Reply to Thread
Results 1 to 2 of 2

Modifying existing VBA code to find different file name

  1. #1
    Registered User
    Join Date
    09-03-2010
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Modifying existing VBA code to find different file name

    Hi,
    I currently have a functioning spreadsheet with VBA code that takes date from an existing database file somewhere else on the network and inserts it into my sheet as a pivot table. The code that identifies what filename to find is shown below:
    Please Login or Register  to view this content.

    The filename falls under a directory later identified in the code, but the filename representation is something like this:

    2010 09 01 0000 (Wide).DBF

    What I'd like to do is modify this code to obtain the previous month's data as well, but I struggle to understand how the code above works exactly. I've tried modifying the last two lines dozens ways with poor results. Specifically only the last line seems to matter when I change it, and I do not understand where the "~2" comes into play, is that some sort of wildcard?

    I've tried replacing & Month1 & with & (Month1 - 1 ) & and it comes back and says "cannot find 20108~2", and even if I rename a file 20108 01 0000 (wide). It seems to change the formatting of the file its looking for whenever I introduce the formula, but even modifying the file name and playing around enough with the formula will not return the desired results. Also, I"ve tried placing the entire file name structure in the last line, similar to the 2nd to last line, but it returns with the message that it cannot find the file name "... [Wide]" instead of (Wide), and I cannot seem to find any way around the parenthesis turning into brackets.

    I feel like i'm missing some fundamental issue here. Any guidance is appreciated, thanks.
    Last edited by Leith Ross; 09-03-2010 at 02:51 PM. Reason: Added Code Tags

  2. #2
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Re: Modifying existing VBA code to find different file name

    Hello PittsburghEng
    I think that It's the MS-DOS file name you're looking for. When a name is too long and the beginning is the same, only the ending changes ~2 ~3 etc. If you're still using an older system you should be able to see the MS-DOS name by using CMD and using C D to get the directory in question and then typing DIR. I have Windows Vista and I don't see the tilda anymore. PS ( there's no space between C D )
    Gordon in Rovereto, Italy

+ 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