+ Reply to Thread
Results 1 to 12 of 12

To rename a workbook filename with the column value of a worksheet.

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    To rename a workbook filename with the column value of a worksheet.

    Hi i have attached an excel workbook by name Threshold_Report.xlsx,I need to rename this with value which is present in worksheet2 of E column of 2row.the renamed workbook should look like :52462_Threshold_Report.xlsx.

    Please look into the workbook which is attached for better understanding.This should work automatically by a vb script or macro.

    path:D:/test/folder/threshold.report
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: To rename a workbook filename with the column value of a worksheet.

    You want the file to be renamed or saved with a different name in a different location?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    File to be renamed will be better or the second option also no problem

  4. #4
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    The value in worksheet2 of E column will change for each run,the one which is coloured in yellow.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: To rename a workbook filename with the column value of a worksheet.

    So each time you want the existing file to be saved with a new name?

  6. #6
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    for first run it genrerates one report with name Threshold_report,this we are renaming to 52462_Threshold_report and next run it generates another report with same name as Threshold_report,here also we are renaming according to the value which is ther in the 2nd worksheet of E2 column.....This process repeats.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: To rename a workbook filename with the column value of a worksheet.

    Ok, so where will the macro be located? In an independent file?

  8. #8
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    yes in an independent file ,where we can choose input file path and output

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: To rename a workbook filename with the column value of a worksheet.

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  10. #10
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    Thanks Arul,actually with above code there is again a manula intervention for selecting the file,so i have altered the above code little:

    Please Login or Register  to view this content.
    Moderator's Note: Don't forget to add code tags on your codes.

    I am new to VBA programming,I need your help here again...the file is getting saved correctly but there is old file existing Threshold_Report in the folder,can we delete this in the same macro?
    Last edited by vlady; 10-18-2012 at 01:54 AM.

  11. #11
    Registered User
    Join Date
    10-10-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: To rename a workbook filename with the column value of a worksheet.

    I was able to delete the existing excel file also.Thanks arlu.Please mark it has solved:
    Please Login or Register  to view this content.
    Last edited by arlu1201; 10-18-2012 at 04:28 AM.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: To rename a workbook filename with the column value of a worksheet.

    Vlady pointed this to you in your previous post and i am doing it again -

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.

+ 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