PC Review


Reply
Thread Tools Rate Thread

Copy data from new file in a folder

 
 
K
Guest
Posts: n/a
 
      22nd Nov 2008
Hi all, I have a macro in "Sheet1" which copies the data from all the
files which are in folder ("C:\Test"). The files which are in this
folder have six digit number in their names. Like for example (see
below)
Record 556987 entry.xlsx
Record 587945 reg.xlsx
Record 547896 fig.xlsx
etc

the macro also extract that six digit number from the files name from
where it copies the data and put those six digit numbers in column A
of "Sheet1" so I know from which files I have copied the data. Time to
time new files get save in folder ("C:\Test") by my self and my
colleagues and every time when i know there are new files in the
folder i run macro to update "Sheet1" so i can have latest data copied
from the files. At the moment macro opens all the files one by one
and copies the data from the files and extract six digit numbers from
their name and close those files. i want some code that macro first
look in six digit numbers in files name and match them with six digit
numbers in column A of "Sheet1" and if there is new file with new six
digit numbers in its name then macro should only open that to copy the
data instead opeing all the files from which i have already copied the
data. Please can any friend can help.
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      22nd Nov 2008
Hi

Maybe something like this:

Sub PPP()
Dim TargetRange As Range
Sheets("Sheet1").Activate
Set TargetRange = Range("A1").End(xlDown)

'your loop to open files, before next file is opened,
'insert next lines and fit to suit
TargetNum = Mid("NextFileName", 8, 6)
Set f = TargetRange.Find(what:=TargetNum, after:=Range("A1"),
lookat:=xlWhole)

If f Is Nothing Then
'New filename
'
' Your code to open file and import data

End If
'Next
End Sub

Regards,
Per

On 22 Nov., 19:34, K <kamranr1...@yahoo.co.uk> wrote:
> Hi all, *I have a macro in "Sheet1" which copies the data from all the
> files which are in folder ("C:\Test"). *The files which are in this
> folder have six digit number in their names. *Like for example (see
> below)
> Record 556987 entry.xlsx
> Record 587945 reg.xlsx
> Record 547896 fig.xlsx
> etc
>
> the macro *also extract that six digit number from the files name from
> where it copies the data and put those six digit numbers in column A
> of "Sheet1" so I know from which files I have copied the data. Time to
> time new files get save in folder ("C:\Test") by my self and my
> colleagues and every time when i know there are new files in the
> folder i run macro to update "Sheet1" so i can have latest data copied
> from the files. *At the moment macro opens all the files one by one
> and copies the data from the files and extract six digit numbers from
> their name and close those files. *i want some code that macro first
> look in six digit numbers in files name and match them with six digit
> numbers in column A of "Sheet1" and if there is new file with new six
> digit numbers in its name then macro should only open that to copy the
> data instead opeing all the files from which i have already copied the
> data. *Please can any friend can help.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy data from all the file file from a folder. Heera Microsoft Excel Programming 3 18th Aug 2008 03:14 PM
How do I copy a sound/pic from my resources folder/resx file in my project to a folder in mydocs? yatrix7@hotmail.com Microsoft VB .NET 0 23rd Aug 2006 03:48 PM
File copy error "Destination Folder is a Subfolder of the Source Folder Frank Windows XP Basics 0 14th Apr 2004 09:34 PM
Re: File copy error "Destination Folder is a Subfolder of the Source Folder Michael Solomon \(MS-MVP Windows Shell/User\) Windows XP Basics 0 14th Apr 2004 07:52 PM
cannot copy folder to new drive: error... cannot copy file Chris Windows XP General 3 14th Mar 2004 09:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 AM.