+ Reply to Thread
Results 1 to 7 of 7

Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    usa
    MS-Off Ver
    2007
    Posts
    8

    Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    I use it to rename all the files in a folder based on the text that exists in cell B1.
    Can you add some more code which would give me a prompt to enter 7 more characters to put right before .xls?

    Here is the existing VBA code.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 06-26-2014 at 09:09 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    Please Login or Register  to view this content.
    Replace the above line in your code with the following:
    Please Login or Register  to view this content.
    This should suffix the user input to the file name (just before the .xls)
    HTH!

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    usa
    MS-Off Ver
    2007
    Posts
    8

    Smile Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    Thanks for working on this code which I guess I should soon learn to do myself. I guess I hadn't explained what I wanted very well. I would like the suffix to be the same for all of the files.
    Last edited by chrisd2000; 06-27-2014 at 02:56 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    In that case, we just need the user to enter the 7Characters once; which can be done anytime before the Do-While Loop (as follows):
    Please Login or Register  to view this content.
    HTH!

  5. #5
    Registered User
    Join Date
    06-23-2014
    Location
    usa
    MS-Off Ver
    2007
    Posts
    8

    Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    jewelsharma, It works, thanks!!!

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    Happy to help. As you now have a working solution, please mark this thread as "Closed".
    Cheers!

  7. #7
    Registered User
    Join Date
    06-23-2014
    Location
    usa
    MS-Off Ver
    2007
    Posts
    8

    Re: Can anyone here tweek this macro for renaming Excel files based on a cell's contents?

    My IT guy says I have to know what macro code does before I can use it so that I am not running malicious code. I got someone to alter it so that I can put in the Walmart calendar week into the filename. So I am trying to Google various parts of the code and I have found some useful explanations. Can you fill in the gaps? Here is what I found so far: With Application.FileDialog(msoFileDialogFolderPicker) selects a folder from a certain path and import all the files inside it http://stackoverflow.com/questions/1...cker-using-vba

    filepath = .SelectedItems(1) 'puts the filepath of the selected file in the variable filepath - See more at: http://lroedal.net/en/vba/read-from-....Od11itRI.dpuf or http://lroedal.net/en/vba/read-from-text-file

    Set wb = Workbooks.Open - the file path you selected in FileDialog - http://stackoverflow.com/questions/2...-manipulate-it
    Last edited by chrisd2000; 07-01-2014 at 04:44 PM.

+ 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. Can a macro rename Excel files based on a cell's contents?
    By chrisd2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2014, 09:51 AM
  2. Excel Macro to save several text files, based on the contents of two cells.
    By chronologie2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 11:31 AM
  3. Creating, copying and renaming new worksheet based on specific cell contents
    By johnejo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 01:16 PM
  4. Rename Excel files based on cell contents
    By remco_t in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2012, 06:10 PM
  5. need macro for renaming bunch of excel files
    By neowok in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2005, 02:05 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