+ Reply to Thread
Results 1 to 6 of 6

Saving a File as a Name & Month

Hybrid View

  1. #1
    Registered User
    Join Date
    03-18-2007
    Posts
    36

    Saving a File as a Name & Month

    Hi there,

    I need VBA that will save a file as a customers name (say XYZ Pty Ltd) and the month/year (mm yy). There is a date in cell E2 that I use as a reference.

    Can anyone help please?

    Thank you.

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

    ActiveWorkbook.SaveAs "companty here" & Format(Month(Cells(2, 2).Value) _
    & Day(Cells(2, 2).Value), "mm yy")
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-18-2007
    Posts
    36

    Saving a File as a Name & Month

    Hi Roy,

    I tried this code but it causes an error. Seems it wants to finish after "company here" and not add - & Format etc.

    Can you help me please?

    Thank you.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You will need to add the path to save to.

    I've amended the code
    ActiveWorkbook.SaveAs "company here" & Format(Cells(2, 2).Value, "mm yy") & ".xls"
    Last edited by royUK; 10-31-2008 at 04:44 AM.

  5. #5
    Registered User
    Join Date
    03-18-2007
    Posts
    36

    Saving a File as a Name & Month

    Hi Roy,

    Thank you for your reply.

    I have tried the code and added on the pathway where I want the file saved but I must be doing something incorrectly - keep getting error messages.

    The pathway is H:/XYZ Ltd Folder.

    Could you please guide me from here?

    Thank you.

    PS. The date I referred to in Cell E2 is always last months date. So in November I will do a report on October transactions so the file needs to be named XYZ Ltd Oct 08.xls.

    Thanks again.

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

    Sub backUp()
    Const sPath As String = "H:/XYZ Ltd Folder"
    Const sCo As String = "XYZ Ltd"
    ActiveWorkbook.SaveAs sPath & Application.PathSeparator & sCo & "_" & _
        Format(Cells(2, 5).Value, "mm yy") & ".xls"
    End Sub

+ 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