+ Reply to Thread
Results 1 to 5 of 5

file/workbook name according to cells value

  1. #1
    Registered User
    Join Date
    10-04-2014
    Location
    israel
    MS-Off Ver
    2010
    Posts
    24

    Post file/workbook name according to cells value

    hi

    i want to auto rename excel file(workbook name) according to cells values. for example:

    currently file name : blank.xlsx

    after i opened the file i paste values in the cells:

    a1=2014 09 01
    a2=New York

    i want the file name to be:

    2014 09 01 PermanentOpening_New York.xlsx

    when "PermanentOpening" is permanent to all the files names and i want the city and the date to be the variables


    it is possible?

    thanks:]

  2. #2
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: file/workbook name according to cells value

    Quote Originally Posted by shaykos View Post
    hi

    i want to auto rename excel file(workbook name) according to cells values. for example:

    currently file name : blank.xlsx

    after i opened the file i paste values in the cells:

    a1=2014 09 01
    a2=New York

    i want the file name to be:

    2014 09 01 PermanentOpening_New York.xlsx

    when "PermanentOpening" is permanent to all the files names and i want the city and the date to be the variables


    it is possible?

    thanks:]
    add this line to your code..
    "C:\Users\xyz\Desktop\Training\OPS\" & Range("a1").Value & " PermanentOpening_" & Range("a2").Value & ".xlsx"
    Last edited by sakmsb; 10-04-2014 at 02:28 PM.

  3. #3
    Registered User
    Join Date
    10-04-2014
    Location
    israel
    MS-Off Ver
    2010
    Posts
    24

    Re: file/workbook name according to cells value

    hi

    it gives me an

    "line number or label or statement or end of statement" error

    by the way- im suppose to replace this: "C:\Users\xyz\Desktop\Training\OPS\"

    in this "c:/users/home/desktop/blank" in my situation?

  4. #4
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: file/workbook name according to cells value

    Quote Originally Posted by shaykos View Post
    hi

    it gives me an

    "line number or label or statement or end of statement" error

    by the way- im suppose to replace this: "C:\Users\xyz\Desktop\Training\OPS\"

    in this "c:/users/home/desktop/blank" in my situation?
    Yes...

    if you are having issues, plz update your code here, someone will look into it.
    If I've been of help, plz add reputation.

  5. #5
    Registered User
    Join Date
    10-04-2014
    Location
    israel
    MS-Off Ver
    2010
    Posts
    24

    Re: file/workbook name according to cells value

    i got this eventually

    Sub SaveFile()

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Dim name As String
    Dim path As String

    name = Sheet1.Range("F3") & " " & "Report_" & Sheet1.Range("F4")
    path = ActiveWorkbook.path

    ActiveWorkbook.SaveAs Filename:=path & "\final\" & name, FileFormat:=51

    Sheet1.Unprotect Password:="1234"
    Range("A1:J155").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues
    Worksheets("T").Delete
    Worksheets("S").Delete
    ActiveWorkbook.SaveAs Filename:=path & "\closed\" & name, FileFormat:=51

    ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=path & "\closed\" & name

    ActiveWorkbook.Close

    End Sub

+ 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. [SOLVED] Copy range to new workbook w/some cells as values & some cells as formulas in new workbook
    By happydayze in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2013, 12:42 PM
  2. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  3. [SOLVED] Link cells to a different workbook file question
    By LKM Kevin in forum Excel General
    Replies: 17
    Last Post: 05-08-2012, 09:53 AM
  4. Macro to copy data from csv file base on cells in existing workbook
    By wallstudio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2011, 03:29 AM
  5. How to insert criteria into the FILE-PROPERTIES box from cells in a workbook?
    By DelMonte in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2008, 05:30 AM

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