Copying a formula from one Excel worbook to another Excel workbook

pincivma

Board Regular
Joined
Dec 12, 2004
Messages
206
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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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
Back
Top