PC Review


Reply
Thread Tools Rate Thread

Capture data in one 'destination' file from varied 'source' file stored in one single folder.

 
 
Smits
Guest
Posts: n/a
 
      3rd Oct 2006
Dear all,
This would be my first encounter with people - geniuses in excel
programming. I have 1% knowledge in visual basic, specifically in
excel.

Help req for the following:
There is one destination file named Sales Tracker (EXCEL FILE)
There are 'n' no of source file, for e.g. Company XYZ, Company ABC,
Company PQR, Company XXX (EXCEL FILES)

Task is to capture data from source file {Company XYZ , Company ABC,
Company PQR, Company XXX (EXCEL FILES)} - Range ("C6") sales amt along
with the name of the company appearing in range ("C2") and transpose it
to destination file Sales Tracker.

Sample: Source File 'Xyz file'
A B C
1
2 XYZ
3
4
5
6 100

Sample: Destination File 'Sales Tracker
A B C
Name Sales
1 XYZ 100
2 ABC 200
3 PQR 250
4 XXX 30

The way automation req is:
Destination file shall always be open .
1} Once we show a location of folder where all source files are stored.
It should count the no of files stored in it and a loop that many no of
times, it should be devised in such a manner that it opens a source
file, copies from the currently opened source file and pastes data in
destination file and closes the source file. This, loop should
continues till all the files present in folder are tracked in
destination file Sales tracker.

It has been a tedious task for me.
Request for help....

Thnx ^ n

Smita

 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      3rd Oct 2006
Hi Smita,

See Ron De Bruin's sample code at:

http://www.rondebruin.nl/ado.htm#folder


---
Regards,
Norman



"Smits" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear all,
> This would be my first encounter with people - geniuses in excel
> programming. I have 1% knowledge in visual basic, specifically in
> excel.
>
> Help req for the following:
> There is one destination file named Sales Tracker (EXCEL FILE)
> There are 'n' no of source file, for e.g. Company XYZ, Company ABC,
> Company PQR, Company XXX (EXCEL FILES)
>
> Task is to capture data from source file {Company XYZ , Company ABC,
> Company PQR, Company XXX (EXCEL FILES)} - Range ("C6") sales amt along
> with the name of the company appearing in range ("C2") and transpose it
> to destination file Sales Tracker.
>
> Sample: Source File 'Xyz file'
> A B C
> 1
> 2 XYZ
> 3
> 4
> 5
> 6 100
>
> Sample: Destination File 'Sales Tracker
> A B C
> Name Sales
> 1 XYZ 100
> 2 ABC 200
> 3 PQR 250
> 4 XXX 30
>
> The way automation req is:
> Destination file shall always be open .
> 1} Once we show a location of folder where all source files are stored.
> It should count the no of files stored in it and a loop that many no of
> times, it should be devised in such a manner that it opens a source
> file, copies from the currently opened source file and pastes data in
> destination file and closes the source file. This, loop should
> continues till all the files present in folder are tracked in
> destination file Sales tracker.
>
> It has been a tedious task for me.
> Request for help....
>
> Thnx ^ n
>
> Smita
>



 
Reply With Quote
 
Smits
Guest
Posts: n/a
 
      7th Oct 2006
Norman,

One 'Compile Error: Sub or Function Not Defined' is invoked while
running suggested macro.
This msg is prompted for 'LastRow' in macro

Abstract from macro.

'Find the last row with data
rnum = LastRow(sh)

Thnx
Smita

===================================
Norman Jones wrote:
> Hi Smita,
>
> See Ron De Bruin's sample code at:
>
> http://www.rondebruin.nl/ado.htm#folder
>
>
> ---
> Regards,
> Norman
>
>
>
> "Smits" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Dear all,
> > This would be my first encounter with people - geniuses in excel
> > programming. I have 1% knowledge in visual basic, specifically in
> > excel.
> >
> > Help req for the following:
> > There is one destination file named Sales Tracker (EXCEL FILE)
> > There are 'n' no of source file, for e.g. Company XYZ, Company ABC,
> > Company PQR, Company XXX (EXCEL FILES)
> >
> > Task is to capture data from source file {Company XYZ , Company ABC,
> > Company PQR, Company XXX (EXCEL FILES)} - Range ("C6") sales amt along
> > with the name of the company appearing in range ("C2") and transpose it
> > to destination file Sales Tracker.
> >
> > Sample: Source File 'Xyz file'
> > A B C
> > 1
> > 2 XYZ
> > 3
> > 4
> > 5
> > 6 100
> >
> > Sample: Destination File 'Sales Tracker
> > A B C
> > Name Sales
> > 1 XYZ 100
> > 2 ABC 200
> > 3 PQR 250
> > 4 XXX 30
> >
> > The way automation req is:
> > Destination file shall always be open .
> > 1} Once we show a location of folder where all source files are stored.
> > It should count the no of files stored in it and a loop that many no of
> > times, it should be devised in such a manner that it opens a source
> > file, copies from the currently opened source file and pastes data in
> > destination file and closes the source file. This, loop should
> > continues till all the files present in folder are tracked in
> > destination file Sales tracker.
> >
> > It has been a tedious task for me.
> > Request for help....
> >
> > Thnx ^ n
> >
> > Smita
> >


 
Reply With Quote
 
Smits
Guest
Posts: n/a
 
      7th Oct 2006
Norman,
One 'compile error: Sub or Function not defined' is invoked while
running the suggested macro.

This error is prompted for 'LastRow' word

'Find the last row with data
rnum = LastRow(sh)
===========================
Can you pls help me with this.

There are few more queries related to this macro. Just to understand
what function does some keywords perform.

1} Application.ScreenUpdating = False


2} Below mentioned procedure fills filename in array or assigns file
no. for performing loop.

'Fill the array(myFiles)with the list of Excel files in the folder
Fnum = 0
Do While FilesInPath <> ""
Fnum = Fnum + 1
ReDim Preserve MyFiles(1 To Fnum)
MyFiles(Fnum) = FilesInPath
FilesInPath = Dir()
Loop

3} 'Loop through all files in the array(myFiles)
If Fnum > 0 Then
For Fnum = LBound(MyFiles) To UBound(MyFiles)

'Find the last row with data
rnum = LastRow(sh)

'create the destination cell address
Set destrange = sh.Cells(rnum + 1, "A")

' Copy the workbook name in Column E
sh.Cells(rnum + 1, "E").Value = MyPath & MyFiles(Fnum)

'Get the cell values and copy it in the destrange
'Change the Sheet name and range as you like
GetData MyPath & MyFiles(Fnum), "Sheet1", "A1:C1",
destrange, False, False
Next
End If

Norman thnx once more coz somebody informed me prior to posting this
msg that it is impossible to perform this act in macro.


===========================

Norman Jones wrote:
> Hi Smita,
>
> See Ron De Bruin's sample code at:
>
> http://www.rondebruin.nl/ado.htm#folder
>
>
> ---
> Regards,
> Norman
>
>
>
> "Smits" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Dear all,
> > This would be my first encounter with people - geniuses in excel
> > programming. I have 1% knowledge in visual basic, specifically in
> > excel.
> >
> > Help req for the following:
> > There is one destination file named Sales Tracker (EXCEL FILE)
> > There are 'n' no of source file, for e.g. Company XYZ, Company ABC,
> > Company PQR, Company XXX (EXCEL FILES)
> >
> > Task is to capture data from source file {Company XYZ , Company ABC,
> > Company PQR, Company XXX (EXCEL FILES)} - Range ("C6") sales amt along
> > with the name of the company appearing in range ("C2") and transpose it
> > to destination file Sales Tracker.
> >
> > Sample: Source File 'Xyz file'
> > A B C
> > 1
> > 2 XYZ
> > 3
> > 4
> > 5
> > 6 100
> >
> > Sample: Destination File 'Sales Tracker
> > A B C
> > Name Sales
> > 1 XYZ 100
> > 2 ABC 200
> > 3 PQR 250
> > 4 XXX 30
> >
> > The way automation req is:
> > Destination file shall always be open .
> > 1} Once we show a location of folder where all source files are stored.
> > It should count the no of files stored in it and a loop that many no of
> > times, it should be devised in such a manner that it opens a source
> > file, copies from the currently opened source file and pastes data in
> > destination file and closes the source file. This, loop should
> > continues till all the files present in folder are tracked in
> > destination file Sales tracker.
> >
> > It has been a tedious task for me.
> > Request for help....
> >
> > Thnx ^ n
> >
> > Smita
> >


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      7th Oct 2006
Have you read this
(Don't forget to copy the Functions and the GetData macro)

You must copy the function lastrow also in the module


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Smits" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Norman,
> One 'compile error: Sub or Function not defined' is invoked while
> running the suggested macro.
>
> This error is prompted for 'LastRow' word
>
> 'Find the last row with data
> rnum = LastRow(sh)
> ===========================
> Can you pls help me with this.
>
> There are few more queries related to this macro. Just to understand
> what function does some keywords perform.
>
> 1} Application.ScreenUpdating = False
>
>
> 2} Below mentioned procedure fills filename in array or assigns file
> no. for performing loop.
>
> 'Fill the array(myFiles)with the list of Excel files in the folder
> Fnum = 0
> Do While FilesInPath <> ""
> Fnum = Fnum + 1
> ReDim Preserve MyFiles(1 To Fnum)
> MyFiles(Fnum) = FilesInPath
> FilesInPath = Dir()
> Loop
>
> 3} 'Loop through all files in the array(myFiles)
> If Fnum > 0 Then
> For Fnum = LBound(MyFiles) To UBound(MyFiles)
>
> 'Find the last row with data
> rnum = LastRow(sh)
>
> 'create the destination cell address
> Set destrange = sh.Cells(rnum + 1, "A")
>
> ' Copy the workbook name in Column E
> sh.Cells(rnum + 1, "E").Value = MyPath & MyFiles(Fnum)
>
> 'Get the cell values and copy it in the destrange
> 'Change the Sheet name and range as you like
> GetData MyPath & MyFiles(Fnum), "Sheet1", "A1:C1",
> destrange, False, False
> Next
> End If
>
> Norman thnx once more coz somebody informed me prior to posting this
> msg that it is impossible to perform this act in macro.
>
>
> ===========================
>
> Norman Jones wrote:
>> Hi Smita,
>>
>> See Ron De Bruin's sample code at:
>>
>> http://www.rondebruin.nl/ado.htm#folder
>>
>>
>> ---
>> Regards,
>> Norman
>>
>>
>>
>> "Smits" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Dear all,
>> > This would be my first encounter with people - geniuses in excel
>> > programming. I have 1% knowledge in visual basic, specifically in
>> > excel.
>> >
>> > Help req for the following:
>> > There is one destination file named Sales Tracker (EXCEL FILE)
>> > There are 'n' no of source file, for e.g. Company XYZ, Company ABC,
>> > Company PQR, Company XXX (EXCEL FILES)
>> >
>> > Task is to capture data from source file {Company XYZ , Company ABC,
>> > Company PQR, Company XXX (EXCEL FILES)} - Range ("C6") sales amt along
>> > with the name of the company appearing in range ("C2") and transpose it
>> > to destination file Sales Tracker.
>> >
>> > Sample: Source File 'Xyz file'
>> > A B C
>> > 1
>> > 2 XYZ
>> > 3
>> > 4
>> > 5
>> > 6 100
>> >
>> > Sample: Destination File 'Sales Tracker
>> > A B C
>> > Name Sales
>> > 1 XYZ 100
>> > 2 ABC 200
>> > 3 PQR 250
>> > 4 XXX 30
>> >
>> > The way automation req is:
>> > Destination file shall always be open .
>> > 1} Once we show a location of folder where all source files are stored.
>> > It should count the no of files stored in it and a loop that many no of
>> > times, it should be devised in such a manner that it opens a source
>> > file, copies from the currently opened source file and pastes data in
>> > destination file and closes the source file. This, loop should
>> > continues till all the files present in folder are tracked in
>> > destination file Sales tracker.
>> >
>> > It has been a tedious task for me.
>> > Request for help....
>> >
>> > Thnx ^ n
>> >
>> > Smita
>> >

>



 
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
Win2K SP4 and Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 1 19th Nov 2010 08:47 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
Windows 2000 SP4 and Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 0 5th Sep 2003 01:48 PM
Re: I am Back... Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 0 27th Aug 2003 01:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:55 PM.