Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy data for match word from one file to another file | Excel Worksheet Functions | |||
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file | Setting up and Configuration of Excel | |||
macro to autofilter other file and copy in opened file | Excel Programming | |||
VBA Macro to copy an column from one Excel file into another file | Excel Programming |