if link exists then ... or

mcfadwmc

Board Regular
Joined
May 10, 2005
Messages
162
what i want to do is set up a file with links to other files but if the file to link to doesn't exist then get data from somewhere in this file
for example

if a file called C:checker\mon 05.12.05 exists then get data within Mon 05.12.05 from sheet1!B3

if it doesn't exist then get data from sheet3!b3 in this file

hope this explains what i want to do

thanks in advance
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
This is the basic code :-
Code:
Sub test()
    Dim MyLink As String
    Dim BookLinks As Variant
    Dim MyLinkExists As Boolean
    '-----------------------------------
    MyLink = "C:\checker\mon 05.12.05"
    MyLinkExists = False
    BookLinks = ActiveWorkbook.LinkSources
    '--------------------------------------
    '- check links
    If Not IsEmpty(BookLinks) Then
        For i = 1 To UBound(BookLinks)
            If BookLinks(i) = MyLink Then
                MyLinkExists = True
            End If
        Next i
    End If
    '-------------------------------------
    If MyLinkExists = True Then
        ' do something
    Else
        ' do something else
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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