+ Reply to Thread
Results 1 to 9 of 9

Macro to open file name in date format

  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    53

    Exclamation Macro to open file name in date format

    Hi Friends,

    I want my macro to open a file from a folder whose name is bfna_210710 (Name contains yesterday's date). I know the simple code which open the file with today's date. Could you fine tune the below code so that it opens the file with yesterday's date included in the file name.
    Please Login or Register  to view this content.
    thanks in advance
    Last edited by Chetan Chauhan; 07-22-2010 at 04:18 AM.

  2. #2
    Registered User
    Join Date
    07-27-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Macro to open file with VD-1

    Hey ! anybody to help me on this?

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to open file with VD-1

    What's VD-1?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-27-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Macro to open file with VD-1

    Its value date -1 eg
    Please Login or Register  to view this content.
    Last edited by Chetan Chauhan; 07-22-2010 at 04:19 AM.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to open file with VD-1

    Well we aren't psychic,amend the title accordingly & you might get help

    Also,change the PHP Tags to Code Tags
    Last edited by royUK; 07-22-2010 at 04:07 AM.

  6. #6
    Registered User
    Join Date
    03-06-2011
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Macro to open file name in date format

    this is the solution
    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Workbooks.Open Filename:="c:\NARESHBHAI\cm" & Format(Date - 1, "DDMMMYYYY") & "bhav.csv"
    End Sub

  7. #7
    Registered User
    Join Date
    07-29-2013
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to open file name in date format

    Can any one help, How can i find the last file named with the text and date format..
    Suppose
    srik_07152013
    srik_07162013

    If today is 07192013 i want to open the last file based on which is 07162013 how can i?

    Used code, But error

    Sub openthefile()
    Dim i
    i = 1
    Workbooks.Open Filename:="\\1.2.3\abc\xyz_" & Format(Today() - i, "MMDDYYYY") & ".xls"
    i = i + 1
    Loop Until i = 30
    End

    Can any one help?

  8. #8
    Registered User
    Join Date
    07-29-2013
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to open file with VD-1

    Can any one help, How can i find the last file named with the text and date format..
    Suppose
    srik_07152013
    srik_07162013

    If today is 07192013 i want to open the last file based on which is 07162013 how can i?

    Used code, But error

    Sub openthefile()
    Dim i
    i = 1
    Workbooks.Open Filename:="\\1.2.3\abc\xyz_" & Format(Today() - i, "MMDDYYYY") & ".xls"
    i = i + 1
    Loop Until i = 30
    End

    Can any one help?

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,629

    Re: Macro to open file name in date format

    srikeers,
    Unfortunately:
    1. Your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    2. Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Ben Van Johnson

+ 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