List Workbook links in cell

TaskMaster

Board Regular
Joined
Oct 15, 2020
Messages
75
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

Im trying to get the workbook links locations listed into my workbook. I have the following that works okay but would like to amend so that it lists them in the summary tab starting in K31 rather than a new workbook. Is there a quick edit that could be made to achieve this?

VBA Code:
Sub ListLinks()
Dim wb As Workbook
Set wb = Application.ActiveWorkbook
If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
wb.Sheets.Add
xIndex = 1
For Each link In wb.LinkSources(xlExcelLinks)
Application.ActiveSheet.Cells(xIndex, 1).Value = link
xIndex = xIndex + 1
Next link
End If
End Sub
 

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
I just commented out the parts you don't need. If you decide to add it back so that it adds the sheets, you will need to explicitly reference the page where you paste all the links instead of using "ActiveSheet" (I was lazy).

VBA Code:
Sub ListLinks()
Dim wb As Workbook
Dim myLinks
    Set wb = Application.ActiveWorkbook
    If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
        'wb.Sheets.Add
        'xIndex = 1
        'For Each link In wb.LinkSources(xlExcelLinks)
            'Application.ActiveSheet.Cells(xIndex, 1).Value = link
            'xIndex = xIndex + 1
        'Next link
        myLinks = wb.LinkSources(xlExcelLinks)
        ActiveSheet.Range("K31").Resize(UBound(myLinks)).Value = WorksheetFunction.Transpose(myLinks)
    End If
End Sub
 
Upvote 0
Solution
I just commented out the parts you don't need. If you decide to add it back so that it adds the sheets, you will need to explicitly reference the page where you paste all the links instead of using "ActiveSheet" (I was lazy).

VBA Code:
Sub ListLinks()
Dim wb As Workbook
Dim myLinks
    Set wb = Application.ActiveWorkbook
    If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
        'wb.Sheets.Add
        'xIndex = 1
        'For Each link In wb.LinkSources(xlExcelLinks)
            'Application.ActiveSheet.Cells(xIndex, 1).Value = link
            'xIndex = xIndex + 1
        'Next link
        myLinks = wb.LinkSources(xlExcelLinks)
        ActiveSheet.Range("K31").Resize(UBound(myLinks)).Value = WorksheetFunction.Transpose(myLinks)
    End If
End Sub
This is exactly what I was looking for - thank you
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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