Excel

Break External Links

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Jacob Hilderbrand

Description:

This macro will break all external links and replace the formula with the current value. 

Discussion:

You have several external links to get data for a spreadsheet. Suppose you want to email that to someone that doesn't have those external files, this could cause a problem. This macro will replace all the external links with the current value, but will leave all other formulas alone. 

Code:

instructions for use

			

Option Explicit Sub BreakLinks() Dim WS As Worksheet Dim Rng1 As Range Dim Cell As Range For Each WS In ActiveWorkbook.Worksheets With WS On Error Resume Next Set Rng1 = Cells.SpecialCells(xlCellTypeFormulas, 23) On Error GoTo 0 If Not Rng1 Is Nothing Then For Each Cell In Rng1 If Left(Cell.Formula, 2) = "='" Then Cell.Value = Cell.Value End If Next End If Set Rng1 = Nothing End With Next End Sub

How to use:

  1. Open Excel.
  2. Alt + F11 to open the VBE.
  3. Insert | Module.
  4. Paste the code there.
  5. Close the VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Tools | Macro | Macros...
  2. Select BreakLinks and press Run.
 

Sample File:

BreakExternalLinks.zip 7.7KB 

Approved by mdmackillop


This entry has been viewed 196 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express