Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Use Macro to Copy Formula from one Workbook to another

I am trying to copy and paste a block of cells from one workbook to
another workbook. The original file is formulas and the destination file
cells need to have the same same formula.

any suggestions on how to add this into a macro?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Use Macro to Copy Formula from one Workbook to another

What happened to your previous post??

Dim ws1 as Worksheet, ws2 as Worksheet

'Saved workbook will have extension like Workbooks("Book1.xls")
Set ws1 = Workbooks("Book1").Sheets("Sheet1")
Set ws2 = Workbooks("Book2").Sheets("Sheet1")

ws1.Range("A1:B10").Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteFormulas
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I am trying to copy and paste a block of cells from one workbook to
another workbook. The original file is formulas and the destination file
cells need to have the same same formula.

any suggestions on how to add this into a macro?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Use Macro to Copy Formula from one Workbook to another

I understand the first part and can get it to work as one Workbook will
always be the same name. When I try to paste the formulas is where I am
getting hung up.
The workbook that the formula needs to be copied to will change. I have 60
plus files to copy these formulas to. How can I make it be like and
ActiveWorkbook of something like that

"Jacob Skaria" wrote:

What happened to your previous post??

Dim ws1 as Worksheet, ws2 as Worksheet

'Saved workbook will have extension like Workbooks("Book1.xls")
Set ws1 = Workbooks("Book1").Sheets("Sheet1")
Set ws2 = Workbooks("Book2").Sheets("Sheet1")

ws1.Range("A1:B10").Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteFormulas
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I am trying to copy and paste a block of cells from one workbook to
another workbook. The original file is formulas and the destination file
cells need to have the same same formula.

any suggestions on how to add this into a macro?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Use Macro to Copy Formula from one Workbook to another

Try the below which will copy the range A1:B10 of formulas to the 1st sheet
of all the other workbooks which are opened...Is this what you are looking
for ?

ActiveSheet.Range("E1:E6").Copy
For Each book In Workbooks
If book.Name < ActiveWorkbook.Name Then _
book.Sheets(1).Range("E1").PasteSpecial Paste:=xlPasteFormulas
Next
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I understand the first part and can get it to work as one Workbook will
always be the same name. When I try to paste the formulas is where I am
getting hung up.
The workbook that the formula needs to be copied to will change. I have 60
plus files to copy these formulas to. How can I make it be like and
ActiveWorkbook of something like that

"Jacob Skaria" wrote:

What happened to your previous post??

Dim ws1 as Worksheet, ws2 as Worksheet

'Saved workbook will have extension like Workbooks("Book1.xls")
Set ws1 = Workbooks("Book1").Sheets("Sheet1")
Set ws2 = Workbooks("Book2").Sheets("Sheet1")

ws1.Range("A1:B10").Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteFormulas
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I am trying to copy and paste a block of cells from one workbook to
another workbook. The original file is formulas and the destination file
cells need to have the same same formula.

any suggestions on how to add this into a macro?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Use Macro to Copy Formula from one Workbook to another

I am getting hung up on the this line:
book.Sheets(1).Range("E1").PasteSpecial Paste:=xlPasteFormulas

Should I be changing a name or something somewhere to match my data?

"Jacob Skaria" wrote:

Try the below which will copy the range A1:B10 of formulas to the 1st sheet
of all the other workbooks which are opened...Is this what you are looking
for ?

ActiveSheet.Range("E1:E6").Copy
For Each book In Workbooks
If book.Name < ActiveWorkbook.Name Then _
book.Sheets(1).Range("E1").PasteSpecial Paste:=xlPasteFormulas
Next
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I understand the first part and can get it to work as one Workbook will
always be the same name. When I try to paste the formulas is where I am
getting hung up.
The workbook that the formula needs to be copied to will change. I have 60
plus files to copy these formulas to. How can I make it be like and
ActiveWorkbook of something like that

"Jacob Skaria" wrote:

What happened to your previous post??

Dim ws1 as Worksheet, ws2 as Worksheet

'Saved workbook will have extension like Workbooks("Book1.xls")
Set ws1 = Workbooks("Book1").Sheets("Sheet1")
Set ws2 = Workbooks("Book2").Sheets("Sheet1")

ws1.Range("A1:B10").Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteFormulas
Application.CutCopyMode = False

If this post helps click Yes
---------------
Jacob Skaria


"bevchapman" wrote:

I am trying to copy and paste a block of cells from one workbook to
another workbook. The original file is formulas and the destination file
cells need to have the same same formula.

any suggestions on how to add this into a macro?



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 Macro to a new workbook Saalim Excel Discussion (Misc queries) 5 November 17th 08 05:14 PM
copy one macro to another workbook Jay Excel Worksheet Functions 2 September 4th 08 06:03 PM
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Copy workbook, don't copy macro CongroGrey Excel Discussion (Misc queries) 1 June 13th 08 04:56 PM
Copy macro to another workbook FTM Excel Discussion (Misc queries) 4 September 21st 06 08:48 PM


All times are GMT +1. The time now is 05:13 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"