+ Reply to Thread
Results 1 to 7 of 7

Making filepath variable

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Making filepath variable

    Hi folks,

    so I´ve come across another issue today during my work. I needed to make a filepath variable due to the months and dates, but for some reason my previous piece logic is not working here and I wonder if I did it proper last time (cause it was done with trial&error method).

    the thing is, the path is constant up till the end, so lets say its: "C:\users\name\desktop\folder\" and now I have quarter as folder and within i have file with dates (15_01_13 for example)

    so the logic I used in the previous file for the loop and it worked was:

    Please Login or Register  to view this content.
    which at one instance would give lets say

    Please Login or Register  to view this content.
    but for some reason when i tried those question marks today again, they didnt work (old file is still working though). So I got two question - 1) Have I done something wrong....2) as far as I´m aware question marks should represent only numerical symbols (mby im wrong here too) but I need something that represent any symbol in any lenght (such as if you´re searching in totalcommander and you use * for undefined symbol or lenght) cant get that one working in vba code though

    help is much appreciated

    Best regards and thx for help guys

    Soul

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Making filepath variable

    Hi,

    ? is a Single Alphanumeric Character and not just numeric.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Making filepath variable

    Hi xlbiznes,

    yeah as i said i might be wrong about what it can represent I wasnt sure if numeric or alphanumeric but the point is it is single one.

    anyways issue still remains, how to make it work....any suggestions?

    Soul

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Making filepath variable

    Hi,

    if you are looping through the list of files using this filter :

    "C:\users\name\desktop\folder\" & i & "Q\??_" & x & y & "_??.xls"

    if we break this further & "Q\??_" & x & y & "_??.xls" -> the first two ?? stands for the day , what does x and y do ? and the last two ?? marks are for the year.

    What is the output of this code ? do you see any spaces ?
    Last edited by xlbiznes; 12-08-2013 at 09:56 AM.

  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Making filepath variable

    Hi,

    i see i swap those two it should be first xy for days (looping through 0 to 3 and 0 to 9) and then the marks, but it doesnt matter atm....;-)....issue is the same

    output is that it doesnt refer to ? as a symbol that can represent anything but as a solid mark (so when it loops results is like ??_25_??)

    EDIT1: and if i put those marks out of the quotes it doesnt work at all some vba error stops it from working not even runtime

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Making filepath variable

    Hi,

    I tried simulating using this code and it worked.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Making filepath variable

    ok, thx, I´ll try tomorrow morning when i get back to my PC at work...thx mate

  8. #8
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Making filepath variable

    Hi again,

    so I´ve tried (using * instead of the question marks to get more gerenal result) and it works on my workstation aswell, so it seems that the problem is not the code but the hardware of my colleague...:-/....i was wondering what´s wrong with the code when it was running for quite long without issues and so it proved that nothing is wrong with it....anyways thx for your insights and help

    Best regards

    Soul

+ 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] Trying to get the filepath on "Open", but get filepath of a temporary file instead
    By ianpwilliams in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-22-2013, 12:27 AM
  2. Replies: 3
    Last Post: 08-07-2013, 10:16 AM
  3. vlookup variable filepath one file variable can this be done via a function?
    By pauldbaker in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-15-2013, 10:10 AM
  4. [SOLVED] Copying files from a selected filepath to a filepath mentioned in a worksheet's cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 03:59 PM
  5. code for variable filepath
    By jem4614 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2008, 05:15 PM

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