Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy worksheets to new workbook without formulas referencing the old workbook

Posted on 2016-10-04
8
Medium Priority
?
117 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 33

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 720 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 35

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 640 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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 11

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 34

Assisted Solution

by:Rob Henson
Rob Henson earned 640 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 11

Author Comment

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

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 720 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 11

Author Closing Comment

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

971 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