VBA Find external links in unusual places (E.g. Buttons, Charts, conditional formatting etc)

fatboy_1989

New Member
Joined
Oct 10, 2014
Messages
19
Hi

How can I use VBA to find and list on a new sheet where external links exist in:

  • Buttons (ones used to run macros when clicked)
  • Charts
  • Pictures
  • Conditional Formatting
  • Data Validation (e.g. lists)
  • Shapes
  • Pivot Tables
  • Named Ranges
  • Cells (likely to be the "easier" ones to find)

Thanks
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
This is too complicated for me to write a code to help you out (that, and the reason it does not seem you have tried any code yourself), but I can help you out by giving you some tips.

The FIND() function, nor the MATCH() function, can go through all those possible objects you listed. There is no one simple function to do what you are trying to accomplish.

What you could / should do, is to loop through all those individual objects and ranges you listed. Something like the example code as follows:

Code:
Sub searchCF() 'this is not real code. Do not try to execute this

Dim frmula As String
Dim exlinkstr As String

exlinkstr = "https://www.google.com"

For each frmula in ThisWorkbook.Sheets(1).ConditionalFormatting
    if frmula LIKE "*" & exlinkstr & "*" then MsgBox frmula
Next frmula

End Sub

Try to search for getting the right information from these objects. E.g., this link here should help you out getting links from conditional formatting.

The FIND() function is easily usable if you want to find a certain string in a range. Look at this MDOCS page to learn about the FIND() function.


Good luck
 
Upvote 0
Where are these links located, in the code or in one of the button's properties, such as the caption?

If it does not work for buttons, try going through the buttons in a worksheet. Code below goes through the buttons' captions.

Code:
Dim btn as OLEObject
Dim exlinkstr As String

exlinkstr = 'link here

With Workbooks(REF).Sheets(REF)

For each btn in .OLEObjects
    If btn.Text Like "*" & exlinkstr & "*" Then
        MsgBox btn.Name
       
    '>>>>alternatively, change the link
        'startn = Instr(1, btn.Text, exlinkstr)
        'strlength = LEN(exlinkstr)
        'newlinkstr = 'new link
        'btn.Text = Left(btn.Text, startn - 1) & newlinkstr & Right(btn.Text, Len(btn.Text - (strlenght + startn - 1))
    End If
Next btn
End With
 
Last edited:
Upvote 0
The external links are found when right clicking the button.
The assigned macro that is trying to be run refers to a macro within an external spreadsheet
Usually when i try to assign a macro, i choose from the VBA within the exisiting spreadsheet, but i need some VBA code that tells me what buttons have been assigned macro names from other spreadsheets....
So the external link is not within the title/text of the button but actually within the "Macro name:" entry of the "Assign Macro" Window.
I would now know what the external link i am looking for would be, i would need it to be listed for me to show me where is the external link and what it is.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,654
Latest member
mememe101

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