Rename Multiple Files In A Folder Macro
Jun 11, 2009
I have 400ish departmental budget files in a folder that I need to upload to a Sharepoint doc library. The files in the folder will have to exactly match the files we already have set up in sharepoint in order to upload them to the sharepoint site. As it stands now there is only one consistency between the sharepoint files and the budget files in the folder, which is the department number (which every file in both begins with).
I'm thinking some sort of macro will let me insert a sheet into each of the files in the budget folder, which would have a formula that pulls the department number from a certain sheet in the file, and produce the file name I want into a certain cell. Then I would like a macro that goes into each file and renames it based on that cell. I'd like to know if this is possible and if there may be a better way to do it.
View 9 Replies
ADVERTISEMENT
Jun 16, 2014
Macro to rename files
I have following problem, discribed also in the link above.
I need a vba code to
- choose a folder instead of a file
- find all the files in the chosen folder with name that starts with "sz" and end with "_d"
- rename those files by replacing the first 5 numbers that follow sz with 5 different numbers that the user can choose e.g. through a user form.
I imagine the user to open the excel file, click on a form thats linked to a macro. The macro will call a userform and ask the user to choose the folder and type in a textbox the 5 new numbers.
I need the code that will be pasted behind the "OK" button in the userform.
Is this possible with vba?
Here a code i found in the link mentioned above, that i have applied and works - but needs to be modified to meet my needs:
Sub GetImportFileName()
Dim Filt As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As Variant
Dim newname As String
[Code].....
View 2 Replies
View Related
Sep 22, 2013
For the last year I have been downloading cash register X1 and Z1 files onto an SD card. Each night's files (X1 & Z1) are stored in a new folder with the naming convention "RP + [DATE]", (EX: RP120910, [YYMMDD]). I have 265 folders! I need to go through each folder, select the Z1 file (I don't care about the X1, X2 or Z2 files) and rename each with the following naming convention: "Z1 + folder_name + .xls". For Example: Folder RP120910 contains the Z1 file named "Z1_T1729.ECR". After renaming, the file should be "Z1RP120910.xls". As the VBA code loops through each subfolder, selecting and renaming the Z1 files, I would like the new files to be placed into a new folder named "Z1Files". Note: All subfolders are currently in a directory named "RegisterFiles". I am using Excel 2010.
View 3 Replies
View Related
Feb 2, 2009
I want to rename some files that I have in a folder, the names I want to end up with are in an excel sheet.
So the below 2 files are what 2 files are call currently, the file name below is what I want to change it to.
01 - Whigwield - Saturday Night.cdg
01 - Whigwield - Saturday Night - which is a music file.
I want to rename the file to this,
SF010-1 WHIGFIELD - SATURDAY NIGHT
The next file is
02 - Take That – Sure.cdg
02 - Take That – Sure – which is a music file.
I want to rename it to:
SF010-2 TAKE THAT - SURE
View 9 Replies
View Related
Dec 23, 2009
Is it possible to rename pdf files in a folder based on data in active workbook?
View 9 Replies
View Related
Feb 27, 2013
I have excel files in a folder, I need a macro to loop through all files, rename them and save them in another folder. the file's name is available in a cell in each file, I am able to get the file name as text (I had to dig a little to get the text as it was between ""). Well I am stuck right now because the macro is doing what it's supposed to do for one excel file only and does not continue with the rest of the available files for a reason.
VB:
Sub RenameAllFiles()
Dim Bk As Variant
Dim n As Integer
Dim NewName As String
[Code] .....
View 8 Replies
View Related
Feb 19, 2010
I would like to copy every file named "Current Day.csv" from every subfolder found in the folder c: est
Rename the file as the value in A1 (3 digit code) and B1 (date) and save the file into v: est (and the folder name the file orginally came from)
Is that possible? (looking at about 30 filesfolders so if need be I can define the folder names)
View 9 Replies
View Related
Apr 7, 2009
I would like my macro to go to a certain folder- in this case N:Aexeo ClientsJabre2008Excel Diet Run, open each workbook therein ( to this end I have found the first part of the code below on another thread) and perform the ExcelDietMacro (also below). I am missing something though as nothing is happening, would anyone know from a quick glance what is wrong? Should I have these as 2 seperate Sub End Subs or combined into one? I know that the Excel Diet is correct thanks to the original designer and Rory on the forum for getting it adjusted to my needs.
Also each workbook within the folder will have the same password to open, is it possible to insert some code in the macro to do this automatically?
Sub LoopFiles()
Dim MyFileName, MyPath As String
Dim MyBook As Workbook
MyPath = "N:Aexeo ClientsJabre2008Excel Diet Run"
MyFileName = Dir(MyPath & "*.xls")
Do Until MyFileName = ""
Workbooks.Open MyPath & MyFileName
Set MyBook = ActiveWorkbook
Application.Run "ExcelDietMacro"
MyBook.Save
MyBook.Close
MyFileName = Dir
Loop
End Sub
Sub ExcelDietMacro()
'
' ExcelDietMacro Macro.........................
View 9 Replies
View Related
Jan 4, 2014
how I can loop through folders to select files starting with a certain word and copy all of them to a different folder and rename them. The folder structure is given below
Company 1(parent folder)
North South East(sub folder) West(sub folder)
Jan Feb Mar.... Dec Jan Feb Mar.... Dec Jan Feb Mar.... Dec Jan Feb Mar.... Dec
In the above structure, the files are present inside each folders Jan, feb...Dec under the regions North, South East n west. note that I have to select files starting with "Sales" and copy them into a new folder(say results) and rename copied files as Sales1.xls, Sales2.xls etc. (Files are not present in the folder company1, north, south, east and east.)
View 1 Replies
View Related
Aug 16, 2013
i am working with a large data set of excel files . I need to format the sheets in a specified way . i have recorded a marco that does this . I now have the problem of creating an automatic loader that opens the files , carrys out my macro , then closes the files.
For example i have a folder X that has 10 files inside it. i would like to be able to load the first file , carry out the macro, close the file move it folder y . Then look back into Folder X , take the first file it see's , carry out the macro , close the file , move it folder y , the go back to folder x and carrying out this until all the files are done and stopping when the folder is empty
View 1 Replies
View Related
Jun 23, 2013
I have obtained a piece of code from online that runs a macro on multiple files in a single given a single folder. when i implement it though it throws a run time error 424 "object required' and point to 'Documents.Open FileName:=path & file' line of code. Is this because Dim file type is not declared?how do i fix this problem. also, im using excel 2010.A
VB:
Sub Mac()
Dim file
Dim path As String
[Code]....
View 4 Replies
View Related
May 11, 2012
I'm working on a project where I need to import 150 csv files into an Excel2010 workbook, with each csv file being on a seperate worksheet.
I would like to set up a macro to point to the folder I will have these saved in this up so that each month when I get updated csv files I can repeat the process and bring in the new data. how to create this, I'm very new to VBA?
View 1 Replies
View Related
Sep 22, 2010
I need tht How to rename the Filenames in an Folder using macro.. Is it possible, How we can do it..
Example: In an Folder 200files are there with extension .jpg/xls/bmp/txt/doc files, I want to rename tht those files names,
Example1:
Source File: TestImage.jpg
I want rename as
Destination file : image.jpg.
Not only Single file rename..if I want to rename Bulk means?...
View 14 Replies
View Related
Nov 18, 2006
In a folder I have several text files (each text file is a customer statement)
I get the files from the computer dept named randomly, I need to rename each
File to its customer ID number, each ID consists of 15 characters (including the dash characters) and is found on the 3rd row of the file (3rd row , skip one character And count 15 characters ex : 0010-902514-422)
I found a code that renames the text files incrementally (1,2,3…..). I need to modify the code so that instead of renaming the files that way I rename them by their ID number (get the ID of each file while looping then rename It by that ID)
One more thing, can I get the ID then skip 44 characters and attach the following 14 characters to the ID (ex : 0010-902514-422- Lebanese Pound). ttached is a folder containing an excel file with the code and 2 statements
Sub RenFile()
Dim arrFiles As Variant
Dim intCounter As Integer
Dim datFile As Date
Dim strFile As String, strPath As String
strPath = ActiveWorkbook.Path
arrFiles = FileArray(strPath, "*.txt")
For intCounter = 1 To UBound(arrFiles)
strFile = arrFiles(intCounter)
Name strPath & strFile As strPath & intCounter & ".txt"
Next intCounter
End Sub
Private Function FileArray(strPath As String, strPattern As String)
Dim arrDatabase()
Dim intCounter As Integer.............................
View 3 Replies
View Related
Mar 25, 2014
I have a macro attached with attached file; it will list the files then will re-name the files based on other cell
example;
Cell A2 = New.mp4
Cell B2 = ggffrr.mp4
so the file New.mp4 will be renamed to ggffrr.mp4.
it is working fine but the location will be always desktop or documents location
i need from the macro to rename the files and to keep them in the same location.
View 1 Replies
View Related
Jun 23, 2014
Can a macro rename Excel files based on a cell's contents? The problem maybe that I download these files en masse from a website and they all have 54-character long randomly generated filenames which I can rename by selecting all and then use the rename function to get a series of filenames like a, a(2), a(3), ... but I would rather have the files renamed based on the text that exists in cell B1 which is the title of the report. I also read somewhere that this kind of macro only works if the tabs have names like "Sheet 1"
View 1 Replies
View Related
Aug 15, 2012
I have a folder that contains around 45 excel files, each of these files contain a tab called "corp val". (these files change name month to month e.g. Report June, Report July etc)
I am finding on a monthly basis i need to go into each of these excel files and copy the data from the "corp val" tab into a summarized spreadsheet - which i then use the data for various things.
Just wondered if there was a solution to this or will it always be difficult to copy and pasting all the data i need. I am not in anyway an advanced excel user, I am guessing this might be some form of macro in which case I am maybe better to keep doing it the way I was as I am not literate in macros.
View 1 Replies
View Related
Sep 9, 2013
I would like to know if there is a way to modify multiple excel files in a folder. What I need to do is hide various columns, adjust margins, cut and paste certain columns to a different position, and change the page layout. Is all of this possible, or will I need to change each individually? If you need more information, let me know.
View 5 Replies
View Related
Dec 3, 2007
I would like to build an index sheet from multiple sheets in a folder(directory).
Let's say I have a folder with sheetA.xls, sheetB.xls and sheetC.xls. I would like to automatically create an "index" sheet that lists the sheet name and info from cells B2 and cell C3 all on a single row. So my index sheet might look something like this:
sheetA Portland Oregon
sheetB Seattle Washington
sheetC Reno Nevada
View 8 Replies
View Related
Sep 14, 2012
I have a folder in my D drive where I used to keep my Text files after downloading it from our support centeral. I want to Import all these Text files in one excel sheet in a way that data of each file got append in excel sheet below previous file data.I am trying to do this through FSO but unable to do the same.
View 1 Replies
View Related
Oct 17, 2007
Import Multiple Text Files & List Names
I would like to use FileDailogFolderPicker object to prompt the Excel User (me!) to browse to the location of the folder which is required to execute the code below; at the moment I have to change the file path in the VBA code each time I run the macro. The code is run on a Click Event button at present.
Private Sub GetGPCFiles_Click()
test
End Sub
Sub test()
Dim myDir As String, fn As String, ff As Integer, txt As String, a()
Dim x, i As Long, n As Long, b(), t As Long
myDir = "Y:DCCRSP07RSPWE191007131007GPC" 'Have to input this path manually
fn = Dir(myDir & "*.gpc")
Do While fn <> ""
ff = FreeFile
Open myDir & "" & fn For Input As #ff
Do While Not EOF(ff)
Line Input #ff, txt
x = Split(txt, ",")
n = n + 1
Redim Preserve a(1 To n)
a(n) = x
Loop
View 6 Replies
View Related
Mar 27, 2008
I have 100 excel files in a folder need all these files to be saved in txt format in another folder need vba code to do this
View 2 Replies
View Related
Apr 22, 2009
I found the following code to execute a macro in all excel files in a folder. Sounds amazing! I have a code to add to it, however I am having issues getting it to work. take a look at it and let me know what (more like, how many things). I am adding this to the Sheet 1 Worksheet.
View 3 Replies
View Related
Jul 10, 2012
Here is a macro I have found and manipulated for my particular case. The problem is that I want to narrow the search criteria by just pdfs and only those starting with Segment which i know in coding would be something like "Segment" & "*" & ".pfd" or something to those terms but the code uses objects which I'm not too familiar with.
Code:
Sub ListAllFile()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Sheets("Simple Cut Lists (2)")
[Code] ........
How do i set objFile to just pick up my criteria?
View 3 Replies
View Related
Jul 19, 2012
Please look at the code below...need this to open and run FIXId macro, save and close then loop through all files in the specified folder.
Code:
Sub CorrectID()
Dim Wb As Workbook, sFile As String, sPath As String
Dim itm As Variant
Dim strFileNames As String
sPath = "C:UsersXXXDocumentsFlash Repots2012"
sFile = Dir("C:UsersXXXDocumentsFlash Repots2012" & "*.xlsx")
[Code] ....
View 7 Replies
View Related
Nov 25, 2013
Excel macro that "simply" prints out all files in a folder on my local C drive?
E.g. C:example
This folder could contain anything from zero to 50 files.
I'm not sure where to start with the VBA code.
View 2 Replies
View Related
Mar 22, 2008
macro to run as a loop on all files in a given folder but allow for the option to Browse for the folder I want this to run in?
Sub CleanUp()
Dim i#, rng As Range
With Application
.ScreenUpdating = False
.DisplayAlerts = False
For i = Worksheets.Count To 1 Step -1
If Worksheets.Count = 1 Then GoTo e
Set rng = Intersect(Worksheets(i).[11:11,13:13,23:23,25:25], _
Worksheets(i).UsedRange)
With rng
.Replace What:=Chr(32), Replacement:="", LookAt:=xlPart
.Replace What:=Chr(160), Replacement:="", LookAt:=xlPart
End With...........................
View 10 Replies
View Related
Mar 5, 2009
I am trying to process 60+ data files. I've recorded/written macros that do all of the processing, and now I would like to write a loop that will go through a folder with the data files (.txt, tab delimitted), and run the code on each file. I am using the Mac Version of Excel 2004. I have tried to adapt some code that I found in the forums, but after fixing a few errors, now nothing is happening when I run the code. The code is below. I have it in a module in the VBA editor.
length of the code; I'm assuming the problem is in the very beginning or end (the code I added for the loop), as the code in the middle that does the actual processing works.
Sub ProcessData()
Dim strDocPath As String
Dim strCurrentFile As String
strDocPath = "Macintosh HD"":Users:thomasarmstrong:Desktop:SF08_Macrosv2:Loop_test:directory:"
strCurrentFile = Dir(strDocPath & MacID("TEXT"))
View 9 Replies
View Related
Sep 30, 2008
I would like to know how to open multiple excel files from a folder based on the information based in cells down a certain column until the last cell.
I thought it might be something like this but it isn't: ....
View 6 Replies
View Related
Feb 7, 2014
I have two pieces of code that each work, but I am struggling to combine the two.
I started with Ron de Bruin's code to attach multiple files to an email and then found more code that will loop through a folder to attach multiple files to an email.
Essentially, I would like the structure of Ron de Bruin's code, with the ability to have folder paths in the cell range, rather than file names.
Here is the code that works to loop through a folder, but it only works when I have the paths listed in one column, not in a range (e.g. columns C-Z)
Code:
Sub Send_Indv_Files()
Dim OutApp As Object
Dim OutMail As Object
[Code].....
View 4 Replies
View Related