Copying a formula from one Excel worbook to another Excel workbook

pincivma

Board Regular
Joined
Dec 12, 2004
Messages
203
I recorded a macro that copies a formula from workbook1 to workbook2. When I checked the formula in workbook2, I noticed that it had the reference to workbook1. I do not want the formula in workbook2 to reference workbook1 in the formula. Is there a way to avoid referencing workbook1 in the formula? I tried everything but without success.
Thanks
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

=ODIN=

Active Member
Joined
Dec 3, 2009
Messages
288
Can you post the code you are using, and what the formula in workbook1 reads?
 

pincivma

Board Regular
Joined
Dec 12, 2004
Messages
203
Here is the code

Sub Schedule()
'
'
'

'
Windows("Workbook1.xlsm").Activate
Sheets("Sheet1").Select
Range("B5:E19").Select
Selection.Copy
Windows("Workbook2.xlsm").Activate
Sheets("Sheet1").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("B5").Select
End Sub

=IF('Show Info'!L11="","",'Show Info'!L11) This formula is in the "Workbook1.xlsm' workbook When I copy it into the workbook2.xlsm it converts to

=IF('[workbook1.xlsm]Show Info'!L11="","",'[workbook1.xlsm]Show Info'!L11)

I only show one formula but you get the picture. I have many formulas to copy from one workbook to another.
 

=ODIN=

Active Member
Joined
Dec 3, 2009
Messages
288
Sorry, I'm not certain I entirely understand the complexity of what you are trying to do, but I think this might handle the situation you have listed in your last post.

It assumes that workbook2.xlsm has a "Show Info" sheet -- otherwise the formula will error out once moved.


Code:
Sub Schedule()


Workbooks("Workbook2.xlsm").Worksheets("Sheet1").Range("b5:b19").Formula = Workbooks("Workbook1.xlsm").Worksheets("Sheet1").Range("b5:b19").Formula


End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,129,271
Messages
5,635,211
Members
416,847
Latest member
inaramos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top