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
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
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.
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.
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.)
I need a macro in a workbook to look at all the files in the same folder that have "*att*.xls" in the name and determine and copy from the range A15:W515 only the rows that have data in at least columns A, C and D. Each file will vary as to how many rows there will be and there are more than the files with "*att*.xls" in the folder. The data will be on the only worksheet in each file and the worksheet is named "G2WAttendee_xls" the data from all the files need to be copied to the file called "Consolidated webinar reports.xls" (I am using Excel 2003) and to a sheet called "Attendance Data" and added to the end of the last paste.
At the start of the macro the current file "Consolidated webinar report.xls" should be saved to a sub folder of the current directory and have the date saved added to the name. The sub folder is called "Completed reports". The data in the original file on worksheet "Attendance Data" should be deleted.
At the end of the process all the files that have had data copied from them should be moved to the sub folder "Attendance reports consolidated" (This could be done as each file is closed if that is easier).
I have headings in row 1 of the "Attendance Data" worksheet that match the headings in the various files in the folder (which will always be in row 14 of the individual "*att*.xls" files).
The folder with all the files and the "Consolidated webinar report.xls" file is at path "Z:P and S MEvaluationsWebinar series 2012-13TB".
I want to allow users to place files (.jpg, .tif, .pdf, .pps etc) into a network folder and then have my program open each file and display it for 30 seconds then close the file and the application before opening the next file.
1. Set up a loop to get a directory listing of the folder and write the listing to a text file.
2. Open up the text file and get the next filename in it
3. Open the file in the associated application
4. Wait for 30 seconds (or some period of time) and then close the file
5. Repeat steps 2-4
DoIt = 1 While DoIt = 1 Open "C:TempList.txt" for output as #1 Print #1, Files In Folder Close #1
Open "C:TempList.txt" for input as #2 while not eof(2) Line input #2, MyFile Display MyFile on screen Wait for 30 seconds Close MyFile and MyApplication that opened it wend Close #2
I can get the directory listing just fine with no problems
I can open the files in the associated application just fine with no problems.
with closing the application after 30 seconds or some period of time.
I need some code that will allow me to easily send it a filename and it will know how to close the file and the application that opened it.
I have an Excel application (Excel 2003) which is stored in the default Program Files folder by the Installer; for example: c:program fileszxchello.xls. The problem I am running into is this file opens as Read Only in Vista and this is interfering with the running of the application. There is no problem opening the file normally in Windows XP.
I have been able to narrow down the cause of this to the User Account Control system in Vista - if I turn OFF User Account Control, the Excel file opens normally and my application functions normally. Is there another option to open the Excel file without turning OFF User Account Control because some users may find it unacceptable to turn OFF this security feature. Ofcourse, one option is to install the application in another location, outside the Program Folder, and the file would open normally, but the Packaging Wizard that I am using to package the application does not allow me to install the application in any other location and thus, the application installs in the Program Folder and I am running into this problem of the Exel file opening as Read Only. Is there a way out of this situation where I can open the file normally (not as Read Only)?
I am trying to copy a file, rename it, and save it to a new folder. I keep getting a "Compile Error ; Syntax Error" at line FileCopy (ImagePath & oldName, NewPath & newName). I am using Excel 2010.
FileCopy (ImagePath & oldName, NewPath & newName)Sub RenameFiles() 'Renames file based on "sheet 1" - Column 1 Old file name - Column 2 New file name Dim oldName As String Dim myfile As String Dim newName As String Dim ImagePath As String Dim NewPath As String
I is it possible to convert all comma separated text files in a single folder in to excel files. But the requirement is to have 2 sheets in each new file. first to be the full file - with all columns, and in the second sheet to keep only colum A B D G H K L M O P R S T V W from the first sheet. The second sheet name must be the same as the first one but without the first "wlist_" in the name.
One more thing. The third column in the second is called "COUL". there are short letters for colors in french
can they be converted with the sort in English like it goes:
NO = B BA = W RG = R SO = P JA = Y BE = L VE = GY GR = G VI = V MA = BR BJ = TA OR = O
Here is a link to the both CSV and an example excel file with the end result. In this example i haven`t change the shorts for the colors. It takes me too much time with the find and replace function. And at the moment i`m really pushed from time.
I would like to open 3 excel files (with identical names) from 3 different mapped drives eg M,N and O. How can I use Excel VBA to rename these 3 files based on their original locations and save them in a folder in the C drive eg M_Filename,N_Filename and O_Filename.
I have a sheet with two columns; Column "A" has a list of existing filepaths of jpeg files that I would like to rename to the value in Column "B" in the same row. Is it possible for VBA to open each picture file and rename? Or open the parent folder and rename from there?
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.............................
I am trying to rename a lot of files within 1 folder. The Spreadsheet Column A contains all the old file names within a folder and Column B has the new file name. (1)My code is below but I continue getting an error that the file isn't found. (2) I would like to start with row 2 because row 1 will contain the folder path as a result of another macro.
I have used macro to ftped a couple of files to my desktop and save them in a folder but i have problems performing the following.
1) Count the number of files in this directory "C:Summary_Reports_from_VBA". Note that the number of files is not fixed every time.
2) Rename each files to .txt files. (intially files do not have any extension and we do not know the name of the file until it has been ftped over but all files will end with a term "sorts" eg renaming of "xxxsorts" to "xxxsorts.txt")
3) Save each renamed files in an Array such that i can "opentext" each file in an excel worksheet. So if there's multiple files, there will be multiple worksheets.
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"
Is there a code that will search a pre-determined folder for all .xls files containing the word "Temp", and deleting those files?
Example: In the root of drive M, I have several Excel files. Anytime one of the original tracking logs is opened, a temp file of that log is automatically created. I would like to automatically search the drive and delete all files containin the word "Temp".
I've attached a picture of the directory tree, in case that will help. The file will always be named "PO Response Tracking - Temp#######.xls", with ###### representing a series of either 5 or 6 numbers.
vba to copy files (pdf / cad) from various source to destination folders. Column A will list the source of the PDF files, Column B with the file name, Column C with the destination folder. Column D with value Y or N with Y denoting Yes to Copy and No for No. I have like 30000 rows of data.