ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to obtain Cell Address and/or Select all sheet-cells with xlExcelLinks (https://www.excelbanter.com/excel-programming/428513-how-obtain-cell-address-select-all-sheet-cells-xlexcellinks.html)

[email protected]

How to obtain Cell Address and/or Select all sheet-cells with xlExcelLinks
 
2003, 2007


With the code below as a base point: Is there a way to obtain

1) Obtain the address of and/or
2) Select all cells with links?

Sub OpenAllLinks()
Dim arLinks As Variant
Dim intIndex As Integer
arLinks = ActiveWorkbook.LinkSources(xlExcelLinks)

If Not IsEmpty(arLinks) Then
For intIndex = LBound(arLinks) To UBound(arLinks)
ActiveWorkbook.OpenLinks arLinks(intIndex)
Next intIndex
Else
MsgBox "The active workbook contains no external links."
End If

End Sub


TIA EagleOne

Barb Reinhardt

How to obtain Cell Address and/or Select all sheet-cells with xlEx
 
I'd try something like this:

Option Explicit

Sub TestLinks()
Dim myHyperlink As Excel.Hyperlink
Dim myRange As Excel.Range

Set myRange = Nothing

Debug.print ActiveSheet.Hyperlinks.Count

For Each myHyperlink In ActiveSheet.Hyperlinks
Debug.Print myHyperlink.Parent.Address
If myRange Is Nothing Then
Set myRange = myHyperlink.Parent
Else
Set myRange = Union(myRange, myHyperlink.Parent)
End If
Next myHyperlink

If Not myRange Is Nothing Then
myRange.Select
End If


End Sub


" wrote:

2003, 2007


With the code below as a base point: Is there a way to obtain

1) Obtain the address of and/or
2) Select all cells with links?

Sub OpenAllLinks()
Dim arLinks As Variant
Dim intIndex As Integer
arLinks = ActiveWorkbook.LinkSources(xlExcelLinks)

If Not IsEmpty(arLinks) Then
For intIndex = LBound(arLinks) To UBound(arLinks)
ActiveWorkbook.OpenLinks arLinks(intIndex)
Next intIndex
Else
MsgBox "The active workbook contains no external links."
End If

End Sub


TIA EagleOne



All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com