Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How to Copy from One File to Another File

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("Sh eet1").Range("B:B")

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to Copy from One File to Another File

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("Sh eet1").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("Sh eet1").Range("B:B")

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How to Copy from One File to Another File

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("Sh eet1").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").Formu la =
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("Sh eet1").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("Sh eet1").Range("B:B")

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to Copy from One File to Another File

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("Sh eet1").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").Formu la =
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("Sh eet1").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("Sh eet1").Range("B:B")

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How to Copy from One File to Another File

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("Sh eet1").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").Formu la =
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("Sh eet1").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("Sh eet1").Range("B:B")

Thanks.

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 data for match word from one file to another file mishak Excel Worksheet Functions 1 December 2nd 09 02:11 AM
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file [email protected] Setting up and Configuration of Excel 0 March 14th 07 02:13 AM
macro to autofilter other file and copy in opened file matthias Excel Programming 4 August 17th 06 10:52 AM
VBA Macro to copy an column from one Excel file into another file Sam Excel Programming 4 July 3rd 05 03:36 AM


All times are GMT +1. The time now is 03:00 PM.

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

About Us

"It's about Microsoft Excel"