Results 1 to 8 of 8
  1. #1
    BakerMan
    Guest

    Create filename from cell content (2000)

    Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>

    I studied <post#=14743>post 14743</post#> "i think" and I got this macro to work. I need, however, to have the file name to include the date. It can be the date in the sheet or today's date either way. I believe the post covered it, but alas-I just couldn't get it!?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create filename from cell content (2000)

    You can use this line to include the date in C4:

    sFName = "C:My Documents" & Range("C3") & Format(Range("C4"), "yyyyddmm")

    or if you prefer the current date:

    sFName = "C:My Documents" & Range("C3") & Format(Date, "yyyyddmm")

    If you'd rather have the date before the name, just switch the order in the line above. You can also use a different date format, but you shouldn't use slashes / in the format, for file names cannot contain a slash.

  3. #3
    BakerMan
    Guest

    Re: Create filename from cell content (2000)

    That's the Ticket - thankyou

  4. #4
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create filename from cell content (2000)

    Hans,

    Just a small comment about the date format: As you say, slashes can not be used but I like to use Format(Date," yy.mm.dd")
    which starts with a space then adds dots to separate the parts of the date.

    This just makes reading the file names in a directory a little easier.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create filename from cell content (2000)

    That's a matter of personal preference. BakerMan can use the format he likes best, as long as it conforms to the rules for file names.

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Create filename from cell content (2000)

    I am not crazy about using periods as separators. Historically they have been used to separate the name from the extension. You may have problems with files on some systems that seem to have "multiple extensions"

    Steve

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create filename from cell content (2000)

    I agree with Steve, using a dot is not the best as it can confuse some programs that don't handle multiple extensions properly. A dash (minus sign) is much better.
    Legare Coleman

  8. #8
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create filename from cell content (2000)

    Yes, I agree it's just a personal pref.
    Thanks for the info re: the possible confusion with certain apps not recognizing the dot.
    I will change to the minus sign in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •