+ Reply to Thread
Results 1 to 4 of 4

Save file by date

Hybrid View

  1. #1
    Registered User
    Join Date
    09-02-2008
    Location
    Richmond
    Posts
    71

    Save file by date

    I'm trying to save the file by report name, location and date. All this information comes out of cells.


    here is the code, couldn't find the blue box everyone puts their code in

    Private Sub SaveSend_Click()
         'Saves filename as value of A1 plus the current date
         
        Dim newFile As String, fName As String
         'Center location
        fName = Range("c4").Value & "  " & Range("b2").Value & " " & Range("f4").Value
             
        newFile = fName
        
        ChDir _
        "M:\Cir at a Glance\Down Route Report"
        ActiveWorkbook.SaveAs Filename:=newFile
        ChDir _
        "M:\Copy of Cir at a Glance\Down Route Report\"
        ActiveWorkbook.SaveAs Filename:=newFile
         
    End Sub

    cell F4 has the date in it but I know why it wont work because of 10/02/08 "/" it changes the file path, how do I format the date to only show 100208 on the file name
    Last edited by James580; 10-02-2008 at 01:49 PM.

  2. #2
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    418
    Hi James

    For your code to show in the window you insert it in your message box, as you have. Put a space line between your question and the first line of your code. Highlight all the code then select the # sign above the window then submit you message

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I think the date in c4 is stored as text. Assuming that's true, then
    Private Sub SaveSend_Click()
        Dim sName As String
        
        sName = Range("c4").Value & " " & Range("b2").Value & " " & Format(CDate(Range("f4").Value), "mmddyy")
        ActiveWorkbook.SaveAs Filename:="M:\Cir at a Glance\Down Route Report\" & sName
        ActiveWorkbook.SaveAs Filename:="M:\Copy of Cir at a Glance\Down Route Report\" & sName
    End Sub
    If you fix it so it's a true date, then
    Private Sub SaveSend_Click()
        Dim sName As String
        
        sName = Range("c4").Value & " " & Range("b2").Value & " " & Format(Range("f4").Value, "mmddyy")
        ActiveWorkbook.SaveAs Filename:="M:\Cir at a Glance\Down Route Report\" & sName
        ActiveWorkbook.SaveAs Filename:="M:\Copy of Cir at a Glance\Down Route Report\" & sName
    End Sub
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    09-02-2008
    Location
    Richmond
    Posts
    71

    Great

    Worked great Thanks

+ 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. Basic file save question
    By spdorsey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2014, 07:21 AM
  2. Excle data file and macro publishing problem
    By sujata_ghosh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-12-2008, 04:19 AM
  3. How to concatenate a variable with a Range
    By Glio in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-07-2008, 09:32 AM
  4. Copy Data from File A to File B
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2007, 05:10 PM
  5. Want to save a file with part of the name derived from an inputbox
    By camcrazy08 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2007, 04:24 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