Move File To Folder Based On Name

Sep 10, 2008

All I have a macro that goes to a "Main" folder modifies the excel sheet and then saves. Is there a way to move that "Modified" sheet to the correct folder after?

All of the excel sheets are named like this:

Bldg _ Date

1130_2008-January
1200_2008-March
1300_2008-January

I need the Bldg # to be a folder.

So all of the Excel files are in this folder: C:Documents and Settingsu369875DesktopProject stuffTestin Save_AS

And then at the end of that I need the bldg Number from the front of the excel name. So for the first one : C:Documents and Settingsu369875DesktopProject stuffTestin Save_AS1130

Or I could even put that building # in the excel at lets say (A1) and grab from there if that would work..

Here is the macro I have as of now. It loops through all of the excels in the folder.

Main Macro (calls out Macro2 & Macro3)

View 14 Replies


ADVERTISEMENT

Excel 2010 :: Copy File / Rename And Move To New Folder

Jan 15, 2013

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

[code]....

View 5 Replies View Related

Save Outlook Attachment And Move Email To A Folder Based And Sender

Feb 23, 2014

I was able to create a macro that saves an email attachment based on the subject and then move it to another folder. I would like changing it to do the same thing only based one the sender’s email. I have it currently reading the save path and subject from the Excel worksheet.

[Code] .....

View 2 Replies View Related

Open File With Name And Folder Based On Cell

Nov 20, 2007

I would like to run a macro that is going to open a file (Test.xls) Simple so far....
However, this file is 1. stored every month in a different folder (eg: 200709,200710, etc..) and the file is named according to the month (eg: Test09.xls, Test10.xls, etc...)
In my excel book, I did created two cells which I already use to save a document according to those cells. One cell with Acct Period (200710) and another one with the month (10).
I have tried the following formula with no success:

OpenWorkbook "\pathpathpath" & Range("Accout Period") & "Test" & Range("Month") & ".xls"

View 9 Replies View Related

File Copy And Create Folder Based On Date

Nov 22, 2011

I want this filecopy to:
1. create a new folder in a subfolder called "/certificates".
2. name that folder the current date. ie. "/certificates/23.11.11".
3. copy the file into that folder.
4. If it's a duplicate then rename the file " - 2" or what ever the next number is.

Code:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False

[Code].....

View 3 Replies View Related

Macro To Save Duplicate File And Create Folder Name Based On Cell Value

Nov 25, 2009

I currently use the following code to create a duplicate file based on two cells within a directory and folder i specify. These cells consist of the team and week commencing date (mondays date of week which is cell 'Main Menu'!K8)

View 7 Replies View Related

Lookup Folder From Cell Text Then Save Excel File In This Folder

May 14, 2014

I have alot of project folders on my harddrive.

All in format: I:/12345-costumer-projectname/

The five digits are unique for each project.

I make calculations for these projects using an excel file. In this excel I also type the projectnumber (cell J2)

Now i would like to make a button. When pressed, it checks the projectnumber cell J2, looksup the corresponding folder and saves the excelfile in PDF format in this folder.

I have found macro to find files in folders, but none which do the above.

View 4 Replies View Related

Excel 2003 :: Extract Variable Rows Of Cells From Files In A Folder To Existing File In Folder

Mar 15, 2013

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".

View 9 Replies View Related

Move Files To Folder By VBA

Aug 6, 2012

In the code below I would like to add to move these files:

byemployee.csv
byposition.csv
status report.xls
bydepartment.csv

and if the file byband.csv exists, then move also otherwise ignore. I want to move to the folder Uploads which is also found under the variable MyPath

If it cannot be included in this code, then I have no problem with a new one.

Private Sub Exitbtn_Click()
Dim MyPath$, MyName$
Application.ScreenUpdating = False
Call chooseView.hideSheets
'Save the file to this path and type file name

[Code]....

View 4 Replies View Related

Move Files From One Folder To Another

Oct 29, 2012

I have the following two folders located in my D Drive:

1. D:FilesData

2. D:FilesArchives

I have lots of files (.txt) in the first folder (D:FilesData) from which I need to move all the files whose first character is starting with _(underscore) to the second folder (D:FilesArchives).

View 1 Replies View Related

Move Files From One Folder To Another Up To Maximum

Feb 7, 2008

I am trying to create a chart that will automatically expand to include additional rows. I have seen posts and examples of the kind of chart I am aiming for, but only showing one series… my chart needs to show several series and be able to add new ones in automatically. For example, I want to make a chart showing the Total Market, and each separate manufacturer, over 13 time periods. If a new manufacturer appears, I would like the chart to show it without having to manually change the source data. (see attached spreadsheet)

View 2 Replies View Related

Files To Move To Folder Created By Another Macro?

Aug 11, 2014

I have the following macro set up to create a folder in a directory as per the contents of 2 cells

C2 = Folder name to be created
B2= Date for previous working day

[code]....

I then have another macro that moves files into a specified folder within the same location ( I then manually move them into the folder the first macro created)

Is there a way I could get the files to move to the newly created folder without me having to do it manually.

View 4 Replies View Related

Move Files To Another Folder Delete Original

Sep 8, 2009

i would like to be able to move files from one folder to another then delete the original files.
I dont think im passsing the variables to the functions corectly.

View 8 Replies View Related

Look In Specified Folder For All Files, Move Them To Main Workbook

Jul 21, 2008

I have this code so far using Macro Recorder but i wanted to change a few parts which i am not too sure how to do:

Its basically supposed to look in specified folder for all files, move them to Main Workbook & rename them slightly

Sub getcsv()
Workbooks.Open Filename:= _
"C:Documents and SettingsSlimDesktopPositionsChartsAUDCADm1440.csv"
Sheets("AUDCADm1440").Select
Sheets("AUDCADm1440").Move After:=Workbooks("Position Risk Calc v9.8.xls"). _
Sheets(23)
End Sub............................

View 9 Replies View Related

Open Website - Download CSV File / Save As In Specific Folder Under Different Name And File Type

Jul 6, 2012

I am trying to open a website, then for excel to download the csv file, then for it to save it in a specific folder under a specific name and file format (excel).

I am successful at opening the website with the following code, but how to do the rest.

Sub Searchez()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://quote.morningstar.ca/Quicktakes/stock/keyratios.aspx?t=clwr®ion=USA&culture=en-CA&ops=clear" 'load web page google.com
IE.Visible = True
While IE.Busy
DoEvents
Wend

'IE.Navigate2 "javascript:SRT_keystuts.exportcsv()"
'this is the name of the download link as from when i hover my pointer over download link.
End Sub

View 1 Replies View Related

Extract Data And File Names From File In Folder And Paste Into One Sheet?

Jan 13, 2013

The code below looks at file names in column A and then goes to a folder and opens and copies the data in range c2 -lastrow from each file and pastes the data into sheet2.

how I could add to the code so that it also inserts the file name in column c?

It would make it easier to track the data in column B.

VB:
Sub CopyFromFile()
Dim fPath As String
Dim lRow As Long

[Code].....

I have attached a sample workbook. The list of file name is in sheet 1. An example of the output is in sheet 2. The data in column A is dummy data generally spans 100's of rows not just 10 as in the example.

The purpose of the code is to be able to put a list of file names in column a in sheet 1 and extract data from those files in a folder. The data extraction works fine. The reson for adding the file names is so that I know what file the data came from.

View 1 Replies View Related

Get Data From Changing Filenames & Move Files To Another Folder

Nov 22, 2007

I am trying to develop an excel macro to accomplish the following:

-I have a master workbook for collecting data
-One folder will be used to dump excel files into; I don't know the filenames (other than "*.xls"), but I do know from which cells I will need to retreive data (they will be the same for all files)

1. I need to retrieve data from these excel files
2. After getting data from a file, it is then moved to another folder
3. Next the retreive data, then move is performed on the next excel file until there are none left in C:IN

Upon searching this forum, I found a way to open each of these files one by one (without having to know the filenames): Using a script to open unspecified file name

- For me, the obstacle seems to be not knowing how to do what I need to without knowing the filenames

- Again, the issue - retrieve data from these files, then rename/move these files

View 7 Replies View Related

Recursively & Conditionally Move/Loop Through Folder Hierarchy To Fill Array

May 7, 2008

i am use dir to put into an array all the folders in a folder then enter the first folder and repeat. the problem i am having is when it encounters a file it also puts it into the array and then errors once it trys to enter that "folder" (which is a file)

right now the code doesnt do anything but the plan is then to call another subroutine that lists all the files im looking for in a folder (that sub does work)

what am i doing wrong? all the things i can find on google show it the way i am doing it.

Sub GetDirList(topfolder As String)
Dim FolderArray() As Variant
Dim FolderCount As Integer
Dim FolderName As String

FolderCount = 0
FolderName = Dir(topfolder, vbDirectory)
' Loop until no more folders are found
Do While FolderName <> ""
If Not FolderName = "." Then
If Not FolderName = ".." Then
FolderCount = FolderCount + 1
Redim Preserve FolderArray(1 To FolderCount)
FolderArray(FolderCount) = FolderName
End If
End If

View 3 Replies View Related

VBA - Cut File From A Folder And Put Into Another Folder?

Oct 9, 2012

Is there a way I can from vba cut a file from a folder and put in to another folder? And also create a folder? If yes, how can I do this?

Is it better to use dir or scripting.filesystem object?and if there is an advantage to use one over the other.

View 2 Replies View Related

Search Folder For File

Dec 17, 2008

I'm using Excel 2007, so no .filesearch

I want to search a folder for a file containing a certain phrase. Would like to use a case option like in java.

search for file containing "aaa", "bbb", "ccc", or "ddd"

then if file exists

View 14 Replies View Related

Moving Known File To Known Folder?

Sep 23, 2011

I'd like to know if there is any way to move a .wav file located in a local folder to another known local folder?

I do not need to open the file.

I'd like to use a variable for the name of the .wav file if possible. And I'd also like to use a variable for the pathname of both the original folder and the one the file is moving to. (if that makes any difference).

View 1 Replies View Related

How Can VBA Distinguish Between File And Folder

Dec 3, 2012

I thought GetAttr did this but it returns 16 for both files and folders?

View 5 Replies View Related

Compare File Name To Folder Name

Aug 14, 2013

I have two variables one is a file name (string) the other is a folder name (long)

file name: 123478 & 123485 sept 25 2013.xlsx
folder name: 123478 & 123485

Is there a way to compare the two (in red) and if they not are similar give me a pop message.

View 2 Replies View Related

Open All Xls File In The Sub Folder

Jul 28, 2006

I need to open all the excel file in a sub folder
(example : CCostingAccount*.*.xls)

It mean by run a macro, it will allow me to be open all excel file in the Account folder .

View 4 Replies View Related

Creating Folder Beside The Excel File?

Apr 23, 2014

Just striving to have this kind of "picture arrangement's macro" to work, macro that whenever you choose a certain cell and operate it on hotkey it'll:

1. Create a new folder named "PicturesAuto" beside the excel file (wherever the excel file located).

2. Inside folder "picturesAuto it'll create a new subfolder named by the same name of the sheet related to that cell you operated the macro upon. (let's say this cell placed on sheet named: "happysheet"- that'll be the name of the subfolder created.)

3. Inside the subfolder "happysheet" it'll create a new subfolder named by the text of the cell you activated the macro upon (let's say you initially operated the macro on B5 cell -which has the text "montana" so it'll create "montana" subfolder also inside subfolder "happysheet")

4. Lastly instead of having only the text "montana" in "B5 cell" like we had initially before activating the macro, the macro'll also add to that text "montana" the link to "montana" folder (path of excel file->picturesAuto->happysheet->montana)

The way I'm planning to use this is to add a lot of HR pictures inside those folders created by the macro that related to that specific sheet, and that specific cell I've activated the macro upon. Plus just having those pictures so organized is just outstanding in every scale, and the excel file will keep running smoothly without any resource consuming overload.

View 7 Replies View Related

Code To Select A File Instead Of Folder

Jun 2, 2014

I have a code that gives me path of all files inside a folder. I want to modify it.

I want to select files (individually or in group) inside a folder and then get the path. All files are .xlsx in folder.

[Code] .....

View 1 Replies View Related

Loop Through Folder And Add Cells From Each File?

Mar 20, 2014

I have a folder that has multiple files that i would like to pull data from. This data is in the same cell in each file so all i would like to do is add the total value up at the end once it finished looping through all the files and display it on my sheet. Some of these files could have 1 worksheet where others might have 3-4. If I only have 1 file in the folder it works perfectly fine but as soon as the second file opens i get a Subscript Out of Range error (See code below for the line this error occurs on).

[Code] .......

View 6 Replies View Related

Find Newest File In A Folder

Oct 29, 2008

I am doing a project for work at the moment where by I have to manipulate a report compiled by an external program and do various bits and bobs to it. Trouble is, the other program creates a new version every time it runs the report (i.e filename.1.xls, and the next day filename.2.xls, and so on). Is there any way of searching the folder these files are in to find the newest file and select that one as the one to open and manipulate? There will be no files other than these in the folder.

View 5 Replies View Related

Saving CSV File And Sending To A Folder Over And Over Again

Jan 12, 2009

I have this code

View 10 Replies View Related

List File Names From Folder

Apr 30, 2009

Need code to open a browser to select a folder and list the files in that folder in excel. I do not want to include sub directories.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved