Code to 'break links'

Mel Smith

Well-known Member
Joined
Dec 13, 2005
Messages
1,023
Office Version
  1. 365
Platform
  1. Windows
When I copy various worksheets, I need to break the data links on the new worksheet that the original worksheet contained. As I have to do this quite frequently, I'd like to have a macro stored in my Personal Macros Workbook so that I can virtually automate this process. Sometimes there is only one data link whereas at other times there might be three or four to be removed/broken.

Is this possible to do with a macro? Could someone help me with the coding, please?

Mel
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I've managed to get most of my code to work but I'm struggling to overcome the issue of when there is only one link rather than the three I've coded in so far. These, of course have specific names. Is there a way of introducing an IF function to deal with this?

My code looks like this:

Sub Break_Links()
' Break_Links Macro
ActiveWorkbook.BreakLink Name:="https://d.docs########", Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="https://d.doc########", Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="https://d.docs########", Type:=xlExcelLinks
End Sub

Mel
 
Upvote 0
Following my previous post, I omitted to use the correct method of posting - my apologies.

My code looks like this:

VBA Code:
Sub Break_Links()
' Break_Links Macro
ActiveWorkbook.BreakLink Name:="[URL='https://d.docs/########']https://d.docs########[/URL]", Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="[URL='https://d.doc/########']https://d.doc########[/URL]", Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="[URL='https://d.docs/########']https://d.docs########[/URL]", Type:=xlExcelLinks
End Sub
 
Upvote 0
Hello Akbarov, I don't need to find the data links, I want to 'break' them all in one go via VBA.

Mel
 
Upvote 0
It can find and delete all of links.
 

Attachments

  • findlinkform.jpg
    findlinkform.jpg
    45 KB · Views: 7
Upvote 0
Solution
That will teach me to read the full document before replying - many thanks.
Mel
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top