Excel

Delete Hyperlinks, Links, Formulas From Workbook

Ease of Use

Easy

Version tested with

2000 

Submitted by:

johnske

Description:

On running the code, all hyperlinks, internal and external links, and formulae are deleted from the workbook, but all values are retained. 

Discussion:

You may have used all sorts of links and formulae to collate data in a workbook but, once collated, all these links etc. are no longer required. Alternatively, you may wish to forward the workbook with the collected data to someone but you don't want them to have access to your formulae or to have them getting that annoying "Update Links?" message every time they open the workbook. Should you also wish to remove all VBA code, see this entry http://www.vbaexpress.com/kb/getarticle.php?kb_id=93 

Code:

instructions for use

			

Option Explicit Sub DeleteLinksInBook() Dim Ws As Worksheet, FirstSheet As Worksheet Dim Query As VbMsgBoxResult Query = MsgBox("CAUTION: Every single link, formula " & _ "& hyperlink in this " & vbLf & _ "book will be deleted - Do you " & _ "still want to proceed?", vbYesNo, _ "Sever All Links?") If Query = vbNo Then Exit Sub Set FirstSheet = ActiveSheet Application.ScreenUpdating = False For Each Ws In Worksheets Ws.Activate '****remove formulae & external links**** With Cells .Select .Copy Selection.PasteSpecial Paste:=xlValues Application.CutCopyMode = False End With '********************************** '*********Remove Hyperlinks********** Cells.Hyperlinks.Delete '********************************** [A1].Select Next FirstSheet.Activate End Sub

How to use:

  1. Open an Excel workbook
  2. Select Tools/Macro/Visual Basic Editor
  3. In the VBE window, select Insert/Module
  4. Copy and paste the code into the Module
  5. Now select File/Close and Return To Microsoft Excel
  6. Save your work
 

Test the code:

  1. Select Tools/Macro/Macros.../DeleteLinksInBook/Run
  2. Select the various parts that were linked to see that all links are severed
  3. To apply this to just one sheet, you need to look at the allied knowledge-base entry http://www.vbaexpress.com/kb/getarticle.php?kb_id=377
 

Sample File:

DeleteLinks_Book.zip 13.33KB 

Approved by mdmackillop


This entry has been viewed 140 times.

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