Copy Files Based On Part Filename

Nov 29, 2006

I have code that takes full cell with filename, looking for it in certain directory and copying to another directory.


Sheets("Unique").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select

For Each rng In Selection
If rng.Offset(0, 4).Value <> "" And InStr(1, rng.Offset(0, 4).Value, "http") = 0 Then
FileCopy SourcePath & rng.Offset(0, 4).Value, ThisWorkbook.Path & "" & DestPath & "" & rng.Offset(0, 4).Value
End If
Next rng

I want to change the code that it will copy based on number. Any suggestions?

Example:

I have range of filenames.
10989478.MEC0388A-L0_RoHS_globemotors_1.pdf
10989495.Keystone_M1.4cat. zip
10989559.MEC0388A-L0_RoHS_qualtek.pdf
I want to copy files starting with 10989478, 10989495, 10989559. I mean ignore the part after "dot".

View 9 Replies


ADVERTISEMENT

Import Multiple CSV Files From Single Directory And Include All Or Part Of Filename

Jul 18, 2014

I am looking for some VB to import multiple csv files, stored in a single directory, into a single excel worksheet. However I am looking to also include all or part of the filename, so to differentiate each file.

I've attached an example spreadsheet, inc the below code, of what I am trying to achieve.

Current code is (this parsers all .csv files in the specified folder into a single worksheet):

[Code] ......

Attached File : csv_loader.xlsm‎

View 6 Replies View Related

Attach Files To Email Based On Partial Filename?

Jul 31, 2014

I'm currently creating E-mails containing a table of material numbers in the body of the message. The E-mail is generated with a macro from a table in excel. In some folder - say on the desktop - I have PDF files for each material Number. Each file is called 0012345_Product-Name.pdf where 0012345 is the material number (always 7 digits). I want the macro to look for the pdf for each material number found in the table and add it to the E-mail as an attachment. With constant, known file names this wouldn't be much of an issue. However, I'm having trouble getting the macro to only search for the first 7 digits of the filename and select it based on that.

Since we are talking up to several 100 PDF's, it would also be great to zip them, once selected - if at all possible, before attaching them to the E-mail

View 2 Replies View Related

Open File In Directory With Part Of Filename As String

Mar 11, 2014

I have a Workbook "forecast.xlsx" and several Workbooks which have a individual Number in the Filename (E.g. "3960........xls", "3961.......xls etc.) in the same directory as "forecast.xlsx" + projects"

Now, I would like to browse through "forecast.xlsx" in column H, searching for hyperlinks. In Column H are these Projectnumbers located which are used in the filenames above. Whenever the Cell cointains a hyperlink, following should happen (that far i managed it by myself):

- Store the Cellvalue in a String Variable
- Go to the Directory this.workbook + projects
- browse this folder, searching for a File which contains the stored string in its filename
- open the file
- copy a range
- close file
- This.workbook.Activate
- follow the Hyperlink which has been stored as String before
- paste selection
- continue browsing through column H, looking for the next hyperlink.

I have a VBA which runs bugless, but it copies the wrong range, but to the correct destination.

See the code below:

Sub RESLT_INPUT_ALL()
Dim cell As Object
For Counter = 1 To 1000
Set cell = Worksheets("Projects overview").Cells(Counter, 8)
If cell.Hyperlinks.Count > 0 Then

[Code] ......

View 1 Replies View Related

Copy Only Part Of Cells Contents Based On Condition?

Jul 6, 2014

I will have 2 columns. In column B, will be a list of invoice numbers. Now each one starts with the "job number" (Ex. 51APGC01) then a dash and unique number per invoice. (Ex. 51APGC01-01)

In column A, will be a list of Purchase Order numbers sent by the customer so we can bill. Now, sometimes we get one PO for multiple invoices, (Ex. 03, 05, 06, 07.....)

What I am looking to do, is when I get these PO's, I enter them in and then I print a report for our billing Dept. The way the output line (cell) will read, is Job Number, then each unique number: (51APGC01-03, 05, 06, 07)

There are multiple jobs and each one has it's own report, so the job number will be dynamic and defined else where in the workbook. I can define that. It's just getting the numbers after the "-" and putting them in only.

View 5 Replies View Related

Loop Through Files, Using Filename As String

May 8, 2008

I have some code that I use to convert files, and it works well, but I would like to make a couple of changes to it. If I run it now it requires user input for every file that is processed, using the input box. Instead of this I would like to use the filename minus the extension as this input.

The next step is selecting the file using the . Instead of this I would like the user to browse for the folder containing .csv files, and select the folder, then use the macro to loop through all files in the folder.

View 9 Replies View Related

Multiple Lookup: List Of Part Numbers Based On The Product Part Code

Feb 12, 2009

I'm creating a worksheet that gives a list of part numbers based on the product part code. In most cases I can use the following.

=LOOKUP(O6,{0,1,2,3,4},{"NONE (M25)","SMP-55-001","SMP-55-004","SMP-55-008","SMP-55-014"})

so this gives a part number depending on what number is placed in O6. What I need to do know is look at 2 different cells and for each combination of numbers give a different part number. so if A1 is 2 and B1 is 3 give a certain result.

View 3 Replies View Related

List Filename, Location & Attributes Of Files In Folder

May 21, 2008

Sorry that I'm very new in Excel VBA coder. And, for this topic, I don't even know how to start. I want to make a MS Excel database of a numerous files. This database must be consist of Filename, Location, and it's attribute (let's say updated date, size, hidden status)

View 2 Replies View Related

Opening Files With Only Part Of The Name

Nov 25, 2008

I am trying to write a program that will open a group of files whose name is in the format S1T1C1.vfc where the S1T1 part of the name will remain constant (S refers to subject number and T refers to trial number) but the "C1" (condition) will be different every time since we randomize our trials. I have a working loop that will open all the trials for a particular subject but only if I remove the last two letters of the file name in the folder. Is there a way to only look at the first part of the file name (which will be unique) and ignore the last two characters?

View 2 Replies View Related

Macro To Select Multiple Files And Copy Them Based On Criteria?

Mar 10, 2013

This is what I am trying to achieve:

1) Prompt user to select a file (or multiple files)

2) Copy the files that meet certain criteria to a folder

My attempt (fail):
VB:

Sub FILES2SFTP() Dim FileNames As Variant Dim I As Integer Dim fso As Variant Dim Data As String ChDrive "G:" ChDir "G:TEST" Data = InputBox("Enter the date", "Enter the date", Format(Application.WorksheetFunction.WorkDay(Date, -1), "yyyymmdd")) Set fso = [code]....
I get error 424 object not found in this line:

If fso.getfilename(FileNames(I).Name) = ("Name1" & Data & ".xls" Or "Name2" & Data & ".xls") Then

View 3 Replies View Related

Copy Files To New Folder Path Based On Cell List

Mar 14, 2008

Essentially, the Engineering Dept has given me 550 AutoCad files I have dumped into a folder located in this path: C:/DrawingsDump

From these 550 DWG files I need to manually filter and separate 260 drawings that I actually need to use and move them to a folder located in this path: C:/DrawingsFiltered . This manual filtering process takes a lot of time and is tedious work and it has got to be done everytime Engineering changes drawings because they are not kind enough to provide me a delta list.

In Excel 2003 I have setup a list of all 260 drawings I am interested in and that I call my filtered list. Is it possible to create a script that will enable Excel 2003 to compare my filtered list to all of the files inside C:/DrawingsDump, and then copy only those files that match to my Excel Filtered list and then paste only matching files into the C:/DrawingsFiltered folder?

If Excel 2003 can't handle this, is there a third party application that will let me perform a file management function like this with minimum startup time?

View 3 Replies View Related

Auto Copy Part Of Row In A Worksheet To Another Worksheet Based On Criteria

Dec 15, 2009

I'm a novice Excel 2007 user and appreciate all the help I can get. I have a workbook with monthly worksheets in it. When a certain data Type is selected from a drop down menu in that monthly worksheet than I would like to have it automatically enter specific data (Name, Date, Eval, Type) copied to another worksheet (CC) in the same workbook. I have been manually entering the data so far. Another thing, some of the data will be entered into the Monthly worksheets and some will only be manually entered into the CC worksheet so it would need to accomodate both methods of data entry. Please let me know if I need to clarify. I have attached the workbood, too.

View 11 Replies View Related

Pulling Data From Files By Part Of File Name

Oct 4, 2008

I have forms by differnet departments each day. The files are saved as the department's name then date Byrd 82708.xsl. I need a command button that will pull data from three cells in each of these forms. The master list will not be in the same folder as the deparment forms, the cells are E20, f20, f25. I have a text box were the user will input the date, by this date I would like all forms with this date in that folder to have their data pulled from those three cells and returned in master list.

View 5 Replies View Related

Copy A File By Specifying A Partial Filename

Oct 7, 2008

I'm attempting to copy some files into an archive folder in the same main folder. These files appear weekly in a folder that contains numerous other files.

Each of these files has a filename such as:

RAH_MRL_TOP_40_(ddmmyy_TIME)

with time being the time that the report was run.

Every week the filename stays the same but the time and date changes. I was hoping to be able to simply use the "Filecopy" command and specify the source file with a "*" after the main file name. However this does not seem to work.

Is there a simple way to do this? (I dont want more than a few lines of coding really as I will be duplicating it for each file and then changing the file name as needed.

View 9 Replies View Related

Copy And Rename Files In VBA By Searching Multiple Folders For Files?

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

Macro To Save Copy That Uses Specific Filename?

Jun 6, 2013

I want a macro that will save a copy of the current file using specific naming convention. My file is called OTR2CMMASTER - I want the macro to save a copy as OTR2CMSAGE(CURRENTMONTH/YEAR). The OTR2 is a named field (ProjectCode) in the workbook.

View 5 Replies View Related

Copy First And Last Cell In Column Range To Use In Constructing Filename?

Jun 25, 2013

I have users that enter data into a worksheet that has a fixed number of columns. They can enter 1 to many rows. I need to copy the data in cell A3 and concatenate it with the last cell in column A that has visible data. I am using this to construct part of a filename. Here is a snippet of my code, however, I am receiving a run time error 13, Type mismatch.

Dim strFileName As String
Dim dt As String

strFileName = ActiveSheet.Range("A3", Range("A3").End(xlDown)).Copy ' & "_DEV" + "_" + dt)

View 2 Replies View Related

Getting Filename Without Extension And Separating Value Based On Character?

Jan 22, 2014

I want to develop a macro for getting filename without extension and seperating the value into two variables.

Requirement:

I have a folder with 3 subfolders inside.

Each subfolder has few files in it.

I will give main folder as input and it should check all subfolders/main folder for files and take that files and modify as shown in below example:

Example of one file: TEST-123_REV00.pdf

Here TEST-123 is the document name
REV00 is the revision of the document
pdf is as usual the extension.

Now my requirement is to prepare an output file with all these files in a text file.

The output is in this format..

Document Name | Revision Name.

View 4 Replies View Related

Copy Data From One Part# On Sheet 2 To The Same Part# On Sheet 1

Feb 10, 2009

What I am trying to do is automatically move the date received and the total qty received from the Rcvg. Log sheet to the RFMs Release sheet.

The problem is:

1) I don't know what I'm doing

2) On the Rcvg. Log several part numbers that are the same with different Qtys.

3) on the Rcvg. Log the are several part numbers that are the same using different programs.

What I would like to do is combine all the same part numbers with the same program add the total Qty received and paste the date received and total Qty into the RFMs Release sheet in the proper part numbers row.

Is this possible?

Attached is a shortened copy of the spreadsheet normally there about 3000 entries.

View 9 Replies View Related

Macro For Saving Filename Based On Cell Content

Feb 3, 2009

Is it possible to create a macro attached to a button that allows me to save the workbook based on content of 2 cells in the workbook?

I like to save the workbook based on content of cell A4 that contend a text string. After that saving another time with the contend of cell A4 plus cell A9 which contend the today() function. I am doing this because this workbook is constantly updated and a backup copy is done based on the date the file is save.

View 9 Replies View Related

Generate A 6 Digits Code Based On Filename And Time Of Generation?

Aug 20, 2009

I need to enter a revision string into a file.

Basically, I need to combine the filename and its generation time and then encode it into a string (i.e. a 6 digits HEX code or 6 digits using [0-9][a-z][A-Z]) so it would generate a pretty much unique revision number.

So, is there any function that you can think of that would do something similar?
If not, what is the best to tackle this?
Generate a CRC or md5sum?

What would be in your opinion a quick and efficient way to solve this tricky one?

View 10 Replies View Related

Copy Part Of One Cell Into Another

Feb 25, 2013

I have a cell that has this
ALG-g30

And I have another cell that looks like this
ADL G28 Clear Lamp Chimney 8-1/2 inches

I want the cell to look like this
ADL G30 Clear Lamp Chimney 8-1/2 inches

Basically I want to take the g30 and convert the "G" to uppercase and add it with the "30" to the other cell..

I need to do that with 40 rows..

How would I do that?

I copied the rows here down here --- [URL] .......

View 1 Replies View Related

Copy Part Of Text

Jan 17, 2007

My file is included with alot of cell in the following format:
aaaa. bbbbbbb (ccccccc)

I want to copy the first part (aaaa) into column A and to copy the second part (bbbbbbb) in column B. Both part can vary in length: in this case their length were 4 and 7 but basically they can have any length. How can i do this. See also the attached file.

View 9 Replies View Related

Excel 2010 :: Macro To Open XLSM File Based On Latest Date Found In Filename

Feb 11, 2013

I'm on excel 2010 and I have a small group excel files I open everyday. Most of the files are static in name and location. I've got a macro created to open those files, which works fine with workbooks.open and the file path.

There are two report files I want to incorporate into my macro of workbooks to open. The files are created weekly and the files names have the following format: "Report Name (YYYY-MM-DD).xlsm". I don't want to use the file's last modified date because older files may get edited after the more recent ones are created. The files are also not always created on the same day, so the solution needs to be flexible enough to not refer to a specific day of the week or anything.

Macro open an excel file based on the latest date found in filename.

View 9 Replies View Related

Copy / Paste Part Of Column Into A Row

May 13, 2014

I have data that looks like this:

ADD ADD 5
ADD EMPTY 2
AGAINAGAIN26
AGAIN EMPTY17
AGAINBACK 1
ALL ALL 24
ALL EMPTY19
ALRIGHT FINE 1
ALRIGHT OKAY 2
ALRIGHT ALRIGHT3
ALRIGHTEMPTY3
ALRIGHTRIGHT1

I want it to look like this:

ADD ADD EMPTY
5 2
AGAINAGAINEMPTY BACK
26 17 1
ALL ALL EMPTY
24 19
ALRIGHTFINE OKAY ALRIGHTEMPTYRIGHT
1 2 3 3 1

i.e all the entries from column B that have the same thing in column A should be on a row together, with the number from column C under them.

If that's a bit hard then it would be OK if it looked like this:

ADD ADD 5
ADD EMPTY 2

AGAINAGAIN26
AGAIN EMPTY17
AGAINBACK 1

ALL ALL 24
ALL EMPTY19

ALRIGHT FINE 1
ALRIGHT OKAY 2
ALRIGHTALRIGHT3
ALRIGHTEMPTY3
ALRIGHTRIGHT1

test.xlsx

View 5 Replies View Related

Copy Part Of Cell Contents

Dec 2, 2011

I need a way to copy part of contents from a cell, the cell contains product information like size, name and weight of a product, and I need a copy the weight to be put in it’s own cell, here’s a copy of one cell “E65 MAPP SKDV 5 DIGIT 90G ST.K” the information I need from this is “90” the number is always followed by a capital G, but it’s between two and three digits where the lowest is 55G and the highest is 300G. Is this possible?

View 6 Replies View Related

Copy Numeric Part Of String?

Aug 23, 2012

How do I copy the numeric part(11 Digits) of a cell

EG. A1 = "GL CREDIT DDA07 60291627599 ZFT"

I Require "60291627599" in A2

Descr
ANSWER

GL CREDIT 62180577391@DDA ZFT
62180577391

GL CREDIT 62300192854 62300192854 DDA06 ZFT
62300192854

GL CREDIT ACC REC 62273991367 ZFT
62273991367

The numeric 11 digit number is not always in the same position in the cell.

View 2 Replies View Related

Copy Numeric Part Of String

Aug 23, 2012

How do I copy the numeric part (11 Digits) of a cell ,

E.G. A1 = "GL CREDIT DDA07 60291627599 ZFT" in only want "60291627599" in A2

Descr
ANSWER

GL CREDIT 62180577391@DDA ZFT
62180577391

GL CREDIT 62300192854 62300192854 DDA06 ZFT
62300192854

GL CREDIT ACC REC 62273991367 ZFT
62273991367

11 digit not always in same position in cell.

View 7 Replies View Related

Copy Part Of Cell And Paste To New Column

Mar 2, 2012

I want the VB Code to do the following;

For each row in Column C, if the text starts with "Calls from service no", it must extract the last word and paste it into corresponding row in Column A. So if the macro finds a cell in Column C starting with "Calls from service no..", then the last word (the last word will always be a number and is seperated with a space) of this cell must be pasted in cell A45. So it must continue for all occurances in Column C. Sample of text in cell = "Calls from service no 0431324345" and "Calls from service no 3242134254" etc.

I also require similar, but this time it must extract as shown below.
If text is found in Column C starting with "Local" or starting with "Long Distance" or starting with "Mobile", only this text, ie "Local" or "Long Distance" or "Mobile" must be pasted in Column B.

It can be 2 different macros that I can run.

View 9 Replies View Related

Copy Last Part Of Text And Paste To Next Column

Nov 15, 2012

Example: A1, I go to school (001). I would like to copy only (001) and past to B1. like that and process to the last row of A1. or I would prefer manual last row.

View 9 Replies View Related







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