Results 1 to 17 of 17

Using VBA to automatically save the file name from the worksheet cells.

Threaded View

  1. #1
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Question Using VBA to automatically save the file name from the worksheet cells.

    Hi Folks,

    I am after a way of saving the current worksheet (sheet2 Service Report) to a new book and using cells C16 (Customer Name) and F10 (Date) to automatically save as the file name. I also need the folder path to be "C:\Documents and Settings\carl.walker\My Documents\Forms\".

    I have had a crack at it with the code below, although I can get both bits to work well seperatly, I dont understand enough for me to combine them for what I want them to do.

    If anyone could help me with this it would be much appreciated.....
    Thanks in advance :o)
    Carl


    FIRST LINE OF CODE:

    Sub MoveSheets()
    
    Worksheets(Array("ServiceReport")).Copy
    
    Set wbNew = ActiveWorkbook
    With wbNew
        ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\carl.walker\My Documents\Forms\" & "\tester.xlsx"
        .Close
    End With
    End Sub
    SECOND LINE OF CODE:

    Sub SaveMyWorkbook()
    
        Dim strPath As String
        Dim strFolderPath As String
    
        strFolderPath = "C:\Documents and Settings\carl.walker\My Documents\Forms\"
    
        strPath = strFolderPath & _
            Sheet2.Range("b16").Value & " " & _
            Sheet2.Range("f10").Value & ""
    
    
        ActiveWorkbook.SaveAs Filename:=strPath
    
    End Sub
    Last edited by vlady; 11-12-2012 at 09:28 PM. Reason: code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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