PC Review


Reply
Thread Tools Rate Thread

How to Copy from One File to Another File

 
 
=?Utf-8?B?R3JlZW5Jbklvd2E=?=
Guest
Posts: n/a
 
      14th Mar 2007
Hi,

I have some data & formulas in one Excel file and would like to COPY it to
another Excel file. I used the following command lines, but it is not
working. Could you please tell me why?

Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B") =
Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B")

Then, I tried this, but it is not working either!

Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy
Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")

Thanks.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Mar 2007
there isn't anything wrong with the code per se.

The first code will reproduce the cell values as constants with no
formatting (formulas will be copied as the values they produce).

Merged cells could be problematic

What isn't working?

to be more explicit with the first

Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value


the above copies to book1 from book2

assuming the problem isn't just wrapped text:
Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy _
Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")

--
Regards,
Tom Ogilvy




"GreenInIowa" wrote:

> Hi,
>
> I have some data & formulas in one Excel file and would like to COPY it to
> another Excel file. I used the following command lines, but it is not
> working. Could you please tell me why?
>
> Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B") =
> Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B")
>
> Then, I tried this, but it is not working either!
>
> Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy
> Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
>
> Thanks.

 
Reply With Quote
 
=?Utf-8?B?R3JlZW5Jbklvd2E=?=
Guest
Posts: n/a
 
      14th Mar 2007
I am confused too! Here is the circumstances

I have a Excel file named "Book1" and have another Excel file named "Book2".
They are both open, but not SAVED.

If I were to type your code exactly you have below

Sub CopyingExactFormula_DifferentFiles()

Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value

End Sub

I gives me erro with yellow backgroud. However, if I want to copy some
formulas in the SAME file I have following code and it works

Sub Copy_SameFile()
Sheets("Inputs_Pomeroy").Range("a101:ad106").Formula =
Sheets("Analysis_Pomeroy (2)").Range("a101:ad106").Formula
End Sub

I am doing something stupid here?

Thanks!

"Tom Ogilvy" wrote:

> there isn't anything wrong with the code per se.
>
> The first code will reproduce the cell values as constants with no
> formatting (formulas will be copied as the values they produce).
>
> Merged cells could be problematic
>
> What isn't working?
>
> to be more explicit with the first
>
> Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
> Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value
>
>
> the above copies to book1 from book2
>
> assuming the problem isn't just wrapped text:
> Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy _
> Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
>
> --
> Regards,
> Tom Ogilvy
>
>
>
>
> "GreenInIowa" wrote:
>
> > Hi,
> >
> > I have some data & formulas in one Excel file and would like to COPY it to
> > another Excel file. I used the following command lines, but it is not
> > working. Could you please tell me why?
> >
> > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B") =
> > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B")
> >
> > Then, I tried this, but it is not working either!
> >
> > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy
> > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> >
> > Thanks.

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Mar 2007
If they haven't been save, then they don't have a .xls extension:

Sub CopyingExactFormula_DifferentFiles()
Workbooks("Book1").Worksheets("Sheet1").Range("B:B").Value = _
Workbooks("Book2").Worksheets("Sheet1").Range("B:B").Value
End Sub

or

Sub CopyingExactFormula_DifferentFiles()
Workbooks("Book2").Worksheets("Sheet1" _
).Range("B:B").Copy _
Destination:=Workbooks("Book1") _
.Worksheets("Sheet1").Range("B:B")
End Sub

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy



"GreenInIowa" wrote:

> I am confused too! Here is the circumstances
>
> I have a Excel file named "Book1" and have another Excel file named "Book2".
> They are both open, but not SAVED.
>
> If I were to type your code exactly you have below
>
> Sub CopyingExactFormula_DifferentFiles()
>
> Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
> Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value
>
> End Sub
>
> I gives me erro with yellow backgroud. However, if I want to copy some
> formulas in the SAME file I have following code and it works
>
> Sub Copy_SameFile()
> Sheets("Inputs_Pomeroy").Range("a101:ad106").Formula =
> Sheets("Analysis_Pomeroy (2)").Range("a101:ad106").Formula
> End Sub
>
> I am doing something stupid here?
>
> Thanks!
>
> "Tom Ogilvy" wrote:
>
> > there isn't anything wrong with the code per se.
> >
> > The first code will reproduce the cell values as constants with no
> > formatting (formulas will be copied as the values they produce).
> >
> > Merged cells could be problematic
> >
> > What isn't working?
> >
> > to be more explicit with the first
> >
> > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
> > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value
> >
> >
> > the above copies to book1 from book2
> >
> > assuming the problem isn't just wrapped text:
> > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy _
> > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> >
> >
> > "GreenInIowa" wrote:
> >
> > > Hi,
> > >
> > > I have some data & formulas in one Excel file and would like to COPY it to
> > > another Excel file. I used the following command lines, but it is not
> > > working. Could you please tell me why?
> > >
> > > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B") =
> > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B")
> > >
> > > Then, I tried this, but it is not working either!
> > >
> > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy
> > > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> > >
> > > Thanks.

 
Reply With Quote
 
=?Utf-8?B?R3JlZW5Jbklvd2E=?=
Guest
Posts: n/a
 
      14th Mar 2007
Wow, this is great and it works! I did not realized that I needed to save
first.

Thanks, Tom!

GreenInIowa

"Tom Ogilvy" wrote:

> If they haven't been save, then they don't have a .xls extension:
>
> Sub CopyingExactFormula_DifferentFiles()
> Workbooks("Book1").Worksheets("Sheet1").Range("B:B").Value = _
> Workbooks("Book2").Worksheets("Sheet1").Range("B:B").Value
> End Sub
>
> or
>
> Sub CopyingExactFormula_DifferentFiles()
> Workbooks("Book2").Worksheets("Sheet1" _
> ).Range("B:B").Copy _
> Destination:=Workbooks("Book1") _
> .Worksheets("Sheet1").Range("B:B")
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "GreenInIowa" wrote:
>
> > I am confused too! Here is the circumstances
> >
> > I have a Excel file named "Book1" and have another Excel file named "Book2".
> > They are both open, but not SAVED.
> >
> > If I were to type your code exactly you have below
> >
> > Sub CopyingExactFormula_DifferentFiles()
> >
> > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
> > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value
> >
> > End Sub
> >
> > I gives me erro with yellow backgroud. However, if I want to copy some
> > formulas in the SAME file I have following code and it works
> >
> > Sub Copy_SameFile()
> > Sheets("Inputs_Pomeroy").Range("a101:ad106").Formula =
> > Sheets("Analysis_Pomeroy (2)").Range("a101:ad106").Formula
> > End Sub
> >
> > I am doing something stupid here?
> >
> > Thanks!
> >
> > "Tom Ogilvy" wrote:
> >
> > > there isn't anything wrong with the code per se.
> > >
> > > The first code will reproduce the cell values as constants with no
> > > formatting (formulas will be copied as the values they produce).
> > >
> > > Merged cells could be problematic
> > >
> > > What isn't working?
> > >
> > > to be more explicit with the first
> > >
> > > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B").Value = _
> > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Value
> > >
> > >
> > > the above copies to book1 from book2
> > >
> > > assuming the problem isn't just wrapped text:
> > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy _
> > > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > >
> > >
> > > "GreenInIowa" wrote:
> > >
> > > > Hi,
> > > >
> > > > I have some data & formulas in one Excel file and would like to COPY it to
> > > > another Excel file. I used the following command lines, but it is not
> > > > working. Could you please tell me why?
> > > >
> > > > Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B") =
> > > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B")
> > > >
> > > > Then, I tried this, but it is not working either!
> > > >
> > > > Workbooks("Book2.xls").Worksheets("Sheet1").Range("B:B").Copy
> > > > Destination:=Workbooks("Book1.xls").Worksheets("Sheet1").Range("B:B")
> > > >
> > > > Thanks.

 
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
WinVista file copy network timeout to WinXP for file Outlook.pst 2007 Sharpy Microsoft Outlook Discussion 4 29th Apr 2009 06:37 AM
Cant copy or zip a file - File not found or no read permissions" error Jack B. Pollack Windows XP General 2 15th Nov 2008 01:29 PM
Copy from closed excel file and paste to master file then loop for same siles Steve B Microsoft Excel Programming 2 6th Mar 2007 06:36 AM
How do i copy a file from an embedded file to the file system James L Microsoft Dot NET Compact Framework 0 25th Apr 2005 09:24 PM
File.Move vs (File.Copy and File.Delete) Chris Microsoft VB .NET 1 9th May 2004 07:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:30 AM.