Solved

Copy worksheets to new workbook without formulas referencing the old workbook

Posted on 2016-10-04
8
60 Views
Last Modified: 2016-10-13
I can't believe I'm not seeing the immediate solution to this, but I'm obviously not.

I'm copying two sheets to a new workbook.  When I do this the formulas are referencing the original workbook.  I do not want this.  The formulas only reference things that are copied over already (other cells on same tab or other tab that is being copied simultaneously).

How do I either copy without the file references while keeping my cell references or how do I rid myself of the file portion of the formulas while keeping the rest?  Adding code to my current macro is an acceptable solution.

PS - find and replace is a fail because it want't to point to another workbook.  I want to lose all file references, not change them.

For example:  
This in original file                                   =SUM(Annual!C10:C25)
in the new workbook becomes            =SUM([Budget.xls]Annual!C10:C25)                        
I want it back to the original                 =SUM(Annual!C10:C25)
0
Comment
Question by:Ray
8 Comments
 
LVL 28

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 180 total points
ID: 41828695
You may try something like this......

Sub ReplaceFormula()
Dim cell As Range
On Error Resume Next
For Each cell In ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 23)
   If InStr(cell.Formula, "[") > 0 Then
      cell.Formula = WorksheetFunction.Replace(cell.Formula, InStr(cell.Formula, "["), InStr(cell.Formula, "]") - InStr(cell.Formula, "[") + 1, "")
   End If
Next cell
End Sub

Open in new window

0
 
LVL 33

Expert Comment

by:Norie
ID: 41828696
What happens when you save the new workbook and close the original one?
0
 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 160 total points
ID: 41828808
I'm not sure why a search and replace won't work using this method:
1) Immediately after copying the sheet(s) to the new workbook (both workbooks open), execute a replace (shortcut [Ctrl]+[H])
EE-replacefilenames.png
This will only remove the filenames on the displayed sheet.

-Glenn
0
 
LVL 10

Author Comment

by:Ray
ID: 41828872
Guys, I feel like a total noob. I was the problem.  I thought I was copying all sheets I needed, but was not copying out a hidden worksheet.  Thus it was making file references since that sheet didn't exist in the new workbook.

Thanks for the effort!!!!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 31

Assisted Solution

by:Rob Henson
Rob Henson earned 160 total points
ID: 41840134
You could have also used the Edit Links window if it occurs again.

On Data ribbon choose Edit Links, in the list that shows up choose the original file (Budget.xls) and click on change source. Browse to the file that you are working in and click OK, thus changing the source to itself.

Thanks
Rob H
0
 
LVL 10

Author Comment

by:Ray
ID: 41842339
What's the best method for closing this one?  
    Split amongst all or?
0
 
LVL 28

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 180 total points
ID: 41842345
If you resolved the question yourself, you may request to delete the question.
But if answers provided helped you to resolve your issue, you may consider accepting those solutions and split the points.
0
 
LVL 10

Author Closing Comment

by:Ray
ID: 41842376
Solved myself, but the answers did make me think about it more.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now