+ Reply to Thread
Results 1 to 2 of 2

Saving excel workbook as name based on cells

  1. #1
    Registered User
    Join Date
    04-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Saving excel workbook as name based on cells

    Hi,
    Using posts from other threads, I was able to cobble together some code that took the current sheet, exported it to a new workbook, then saved that workbook in a folder based on a cell name, and saved the filename based on a combination of two cells.
    This was working fine last night, but not so this morning. The error that comes up is "400".
    The code is below.

    Sub newexport()

    Dim wb As Workbook

    Worksheets("Exercise Plan").Copy
    Set wb = ActiveWorkbook
    wb.SaveAs Filename:=("C:\Lauren\" & Sheets("Exercise Plan").Range("a2").Value & "\" & "Exercise Plan" & " " & Sheets("Exercise Plan").Range("a2").Value & " " & Sheets("Exercise Plan").Range("c3").Value)
    wb.Close

    End Sub

    A2: Cell specifying name
    C3: Cell specifying program number

    So the filename should read something like: C:\Lauren\Joe Smith\Exercise Plan Joe Smith 12.xls

    Thanks for your help!

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Saving excel workbook as name based on cells

    Welcome to the forum. Pls take few minutes to read forum rules, because:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

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