Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Macro to save a file name as per a cell content. (https://www.askmehelpdesk.com/showthread.php?t=350067)

  • May 5, 2009, 11:49 AM
    rsdjimbie
    Macro to save a file name as per a cell content.
    I have a macro saving the file auto. To my desktop.

    For example cell A1 = 501

    I run a macro with a counter and auto. Changes A1 to 502.

    Now macro must change file saving to 502, or =cell A1 content.

    I also sometimes have to change destination from desktop to a specific file.
  • May 5, 2009, 05:02 PM
    JBeaucaire
    Quote:

    Originally Posted by rsdjimbie View Post
    I have a macro saving the file auto. To my desktop.

    For example cell A1 = 501

    I run a macro with a counter and auto. Changes A1 to 502.

    Now macro must change file saving to 502, or =cell A1 content.

    Building on what we've done earlier, something like this should give an idea of the syntax:
    Code:

    Sub Save()
    Dim fName As String, DTAddress As String
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
    fName = Range("A1").Text

        ActiveWorkbook.SaveAs DTAddress & fName & ".xls"

    End Sub

    Quote:

    I also sometimes have to change destination from desktop to a specific file.
    Change how? Clarify your work process or desired methodology.
  • May 5, 2009, 11:40 PM
    rsdjimbie

    File save as: My documents->Renier-> Production management->May
  • May 6, 2009, 09:06 AM
    JBeaucaire

    Riddles and more riddles.

    If you occasionally want to save the file to a different place and NOT use your macros normal methodology, then don't use your macro.

    Click on File > Save and pick you path / filename.

  • All times are GMT -7. The time now is 12:18 AM.