Solved

Copy worksheets to new workbook without formulas referencing the old workbook

Posted on 2016-10-04
8
83 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 29

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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
 
LVL 32

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 29

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

823 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