+ Reply to Thread
Results 1 to 3 of 3

Error - try to save file named as cell value

  1. #1
    Registered User
    Join Date
    03-08-2019
    Location
    Oakland, CA, USA
    MS-Off Ver
    2016
    Posts
    1

    Error - try to save file named as cell value

    Hello all,

    I try to save my invoice under an assigned directory with the name of cell in the sheet. I try to save the file as the name of cell F4 and G4. The cell content for F4 is “ =LEFT(Branch_bill,3)” and G4 is number. My scripts are as follow:
    Sub SaveAsCellValue()
    'Copy wihtout Macro button

    Sheets("Invoice").Select

    Sheets("Invoice").Copy

    ActiveSheet.Shapes.Range(Array("Button_Next")).Select
    Selection.Delete
    Selection.Cut
    ActiveSheet.Shapes.Range(Array("Button_Summary")).Select
    Selection.Delete
    Selection.Cut
    ‘Save File
    Dim Path As String
    Dim filename As String
    Path = "/Users/nanaliu/Documents/Invoice/
    filename = Range("F4:G4")
    ActiveWorkbook.SaveAs filename:=Path & filename & ".xls", FileFormat:=xlNormal

    End Sub

    The copy part is working well but it fail to save the file.

    Anyone who can help is greatly appericated.

    Thanks in advance.

    Sandy

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Error - try to save file named as cell value

    Sandy.
    Please refresh your memory by reading the forum rules. #2 Comes to mind here.

    Code should be changed at a few places but you might try these changes to start with.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Change references as required.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Error - try to save file named as cell value

    You indicate that you have 2016.
    For saving in different formats (in your code you have .xls), have a read here
    https://www.rondebruin.nl/win/s5/win001.htm

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro for copy,paste from first to 2nd file and save named as first file
    By zarize92 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2018, 09:10 AM
  2. [SOLVED] Cannot save a file - error 5152
    By IonutC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2016, 12:07 PM
  3. [SOLVED] Save to .pdf named after cell value with date in it
    By scrabtree23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2016, 06:22 PM
  4. [SOLVED] Save File Using a named range as the File Path
    By Bigmal70 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2015, 06:22 AM
  5. Error 1004 when trying to save file with name generated from cell value
    By Terios1951 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-15-2015, 04:49 PM
  6. [SOLVED] Save file syntax error
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2015, 12:50 PM
  7. Excel Error on file save
    By Ninjataktikz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2012, 04:55 PM

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