Save file with data from cells in worksheet as filename
Amazing chart utilities from Jon Peltier
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Save file with data from cells in worksheet as filename

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I am looking for a solution that will save a file with data from within the spreadsheet when a user selects "file", "save". I want it to take data from "a1,b1,c1" and save the file with the filename such as "username - date - score" like (mccolk - 022302 - 95) and save it to a specified folder (g:coaching databasemccolk - 022302 -95.xls). If anyone has any suggestions or examples, it would be greatly appreciated. Thanks in advance

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Kevin

    Try modifying this for your needs:

    sub saveme()
    ActiveWorkbook.SaveAs Filename:="C:Documents and SettingsdefaultMy Documentsscores " & _
    ' Format(Sheets("Store Info").Range("d4"), "0 ") & _
    ' Format(Sheets("Store Info").Range("h2"), _
    ' "yy.mmdd") & ".xls"
    end sub

    The above will save a file in the name of Scores+"D4"+"H2(in date format)" in my documents

    HTH

    Dan.

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    363
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Here's a solution that will work with the save button on the toolbar and from File > Save on the menu bar.

    Dim btnSave1 As CommandBarButton
    Dim btnSave2 As CommandBarButton

    Sub Auto_Open()
    Set btnSave1 = CommandBars("Standard").Controls("Save")
    Set btnSave2 = CommandBars("File").Controls("Save")
    With btnSave1
    .Visible = True
    .OnAction = "CustomSave"
    End With
    With btnSave2
    .OnAction = "CustomSave"
    End With
    End Sub
    Sub CustomSave()
    Dim SaveName As String
    Dim Dir As String
    MsgBox "hi"
    Application.DisplayAlerts = False
    Dir = "C:My Documents"
    SaveName = Cells(1, 1) & "-" & Cells(1, 2) & "-" & Cells(1, 3)
    SaveName = Dir & SaveName
    ActiveWorkbook.SaveAs Filename:=SaveName
    End Sub
    Sub Auto_Close()
    CommandBars("Standard").Controls("Save").Reset
    CommandBars("File").Controls("Save").Reset
    End Sub

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com