Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default How do i copy a cell from a workbook to another workbook?

Hi

I have a data in Cells G25. And I have 20 xls files in a folder.

What i want to do is I would like to copy the cells G25 from this 20 xls
files into a new workbook. How could I do that?

Please can i have some help?

Thanks a lot

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default How do i copy a cell from a workbook to another workbook?

Here is one method...

You will need a workbook with the filename "Work.xls" for this one to work
out right. Also you can only have the "Work.xls" file open when you run this
macro or it will not work correctly.

With the workbook "Work.xls" open, make a new module and paste the following
code...

Then run the macro.


Sub OpenFiles()
Dim fn As Variant, f As Integer, i As Integer, counter As Integer

i = 1
fn = Application.GetOpenFilename("CSV Files,*.csv", _
1, "Select One Or More Files To Open",
, True)
If TypeName(fn) = "Boolean" Then Exit Sub
For f = 1 To UBound(fn)
Debug.Print "Selected file #" & f & ": " & fn(f)
Workbooks.Open fn(f)

While i = 1

Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
ActiveSheet.Paste

i = i + 1
Wend

If (f 1) Then

While (i <= f)
Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
Cells(i, 1).Select
ActiveSheet.Paste

i = i + 1
Wend

End If

ActiveWindow.ActivateNext
ActiveWindow.Close False

Next f
End Sub











"Tony" wrote in message
...
Hi

I have a data in Cells G25. And I have 20 xls files in a folder.

What i want to do is I would like to copy the cells G25 from this 20 xls
files into a new workbook. How could I do that?

Please can i have some help?

Thanks a lot

Tony


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default How do i copy a cell from a workbook to another workbook?

You needed it for XLS files... my bad... try the following macro:

Sub OpenFiles()
Dim fn As Variant, f As Integer, i As Integer, counter As Integer

i = 1
fn = Application.GetOpenFilename("Excel Files,*.xls", _
1, "Select One Or More Files To Open",
, True)
If TypeName(fn) = "Boolean" Then Exit Sub
For f = 1 To UBound(fn)
Debug.Print "Selected file #" & f & ": " & fn(f)
Workbooks.Open fn(f)

While i = 1

Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
ActiveSheet.Paste

i = i + 1
Wend

If (f 1) Then

While (i <= f)
Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
Cells(i, 1).Select
ActiveSheet.Paste

i = i + 1
Wend

End If

ActiveWindow.ActivateNext
ActiveWindow.Close False

Next f
End Sub

"Mark Ivey" wrote in message
...
Here is one method...

You will need a workbook with the filename "Work.xls" for this one to
work out right. Also you can only have the "Work.xls" file open when you
run this macro or it will not work correctly.

With the workbook "Work.xls" open, make a new module and paste the
following code...

Then run the macro.


Sub OpenFiles()
Dim fn As Variant, f As Integer, i As Integer, counter As Integer

i = 1
fn = Application.GetOpenFilename("CSV Files,*.csv", _
1, "Select One Or More Files To Open",
, True)
If TypeName(fn) = "Boolean" Then Exit Sub
For f = 1 To UBound(fn)
Debug.Print "Selected file #" & f & ": " & fn(f)
Workbooks.Open fn(f)

While i = 1

Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
ActiveSheet.Paste

i = i + 1
Wend

If (f 1) Then

While (i <= f)
Range("G25").Select
Selection.Copy
Windows("Work.xls").Activate
Range("A1").Select
Cells(i, 1).Select
ActiveSheet.Paste

i = i + 1
Wend

End If

ActiveWindow.ActivateNext
ActiveWindow.Close False

Next f
End Sub











"Tony" wrote in message
...
Hi

I have a data in Cells G25. And I have 20 xls files in a folder.

What i want to do is I would like to copy the cells G25 from this 20 xls
files into a new workbook. How could I do that?

Please can i have some help?

Thanks a lot

Tony


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default How do i copy a cell from a workbook to another workbook?

I got a Excel VBA program which is used to generate report.

All i want to do is

1. Click the generate button
2. Copy the Cells G25 from 10 folders with 20 different xls files
3. generate it to my existing workbook performance score worksheet

Is your macro able to do that?

Thanks for your help

Tony
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default How do i copy a cell from a workbook to another workbook?

Not as it is...

It would need some work...

If you need more in-depth help, give me the path these files are located in
and I will see what I can do from there.

Mark


"Tony" wrote in message
...
I got a Excel VBA program which is used to generate report.

All i want to do is

1. Click the generate button
2. Copy the Cells G25 from 10 folders with 20 different xls files
3. generate it to my existing workbook performance score worksheet

Is your macro able to do that?

Thanks for your help

Tony




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default How do i copy a cell from a workbook to another workbook?

No problem...



"Tony" wrote in message
...
maybe i could send it to you by e-mail? is it ok?

"Mark Ivey" wrote:

Not as it is...

It would need some work...

If you need more in-depth help, give me the path these files are located
in
and I will see what I can do from there.

Mark


"Tony" wrote in message
...
I got a Excel VBA program which is used to generate report.

All i want to do is

1. Click the generate button
2. Copy the Cells G25 from 10 folders with 20 different xls files
3. generate it to my existing workbook performance score worksheet

Is your macro able to do that?

Thanks for your help

Tony


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default How do i copy a cell from a workbook to another workbook?

maybe i could send it to you by e-mail? is it ok?

"Mark Ivey" wrote:

Not as it is...

It would need some work...

If you need more in-depth help, give me the path these files are located in
and I will see what I can do from there.

Mark


"Tony" wrote in message
...
I got a Excel VBA program which is used to generate report.

All i want to do is

1. Click the generate button
2. Copy the Cells G25 from 10 folders with 20 different xls files
3. generate it to my existing workbook performance score worksheet

Is your macro able to do that?

Thanks for your help

Tony


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default How do i copy a cell from a workbook to another workbook?

sent... please check your e-mail

thanks

"Mark Ivey" wrote:

No problem...



"Tony" wrote in message
...
maybe i could send it to you by e-mail? is it ok?

"Mark Ivey" wrote:

Not as it is...

It would need some work...

If you need more in-depth help, give me the path these files are located
in
and I will see what I can do from there.

Mark


"Tony" wrote in message
...
I got a Excel VBA program which is used to generate report.

All i want to do is

1. Click the generate button
2. Copy the Cells G25 from 10 folders with 20 different xls files
3. generate it to my existing workbook performance score worksheet

Is your macro able to do that?

Thanks for your help

Tony


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy cell infromation from workbook to workbook Twistball Excel Discussion (Misc queries) 0 December 14th 08 03:19 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
How copy cell workbook to workbook? [email protected] Excel Discussion (Misc queries) 6 October 21st 05 03:15 PM
Copy cell data Workbook to Workbook Soli3d Excel Programming 2 February 1st 05 08:47 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"