PC Review


Reply
Thread Tools Rate Thread

How do i copy a cell from a workbook to another workbook?

 
 
Tony
Guest
Posts: n/a
 
      20th Dec 2007
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
 
Reply With Quote
 
 
 
 
Mark Ivey
Guest
Posts: n/a
 
      20th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:AEF71159-5254-4EC5-B095-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Mark Ivey
Guest
Posts: n/a
 
      20th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:59DF9AA9-AB30-453F-91C5-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:AEF71159-5254-4EC5-B095-(E-Mail Removed)...
>> 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

>

 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      20th Dec 2007
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 With Quote
 
Mark Ivey
Guest
Posts: n/a
 
      20th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:881C33AF-1CB0-450C-97EB-(E-Mail Removed)...
> 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 With Quote
 
Mark Ivey
Guest
Posts: n/a
 
      20th Dec 2007
No problem...



"Tony" <(E-Mail Removed)> wrote in message
news:9B02A28A-0E79-4A36-B6FF-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:881C33AF-1CB0-450C-97EB-(E-Mail Removed)...
>> > 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 With Quote
 
Tony
Guest
Posts: n/a
 
      20th Dec 2007
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" <(E-Mail Removed)> wrote in message
> news:881C33AF-1CB0-450C-97EB-(E-Mail Removed)...
> > 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 With Quote
 
Tony
Guest
Posts: n/a
 
      20th Dec 2007
sent... please check your e-mail

thanks

"Mark Ivey" wrote:

> No problem...
>
>
>
> "Tony" <(E-Mail Removed)> wrote in message
> news:9B02A28A-0E79-4A36-B6FF-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:881C33AF-1CB0-450C-97EB-(E-Mail Removed)...
> >> > 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 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 workbook to new workbook based on cell value ajd Microsoft Excel Programming 3 5th Feb 2009 12:56 AM
copy cell infromation from workbook to workbook Twistball Microsoft Excel Misc 0 14th Dec 2008 03:19 PM
Copy Range to a New WorkBook + Name Sheet a cell Value + Name WorkBook another Celll Value Corey Microsoft Excel Programming 2 2nd Nov 2006 05:01 AM
How copy cell workbook to workbook? sbrodsky@gmail.com Microsoft Excel Misc 6 21st Oct 2005 03:15 PM
Copy cell data Workbook to Workbook =?Utf-8?B?U29saTNk?= Microsoft Excel Programming 2 1st Feb 2005 08:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 AM.