Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 12-25-2020, 12:16 PM
Purfleet Purfleet is offline Importing a file to a sheet with a hyperlink? Windows 10 Importing a file to a sheet with a hyperlink? Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

A bit basic, but this should do what you want.

The file location needs to be in cell B1 and the file name in B2

Code:
Sub ImportFile()

    Dim fLocation As String
    Dim fName As String
    Dim CurrentfName As String
    
    CurrentfName = ActiveWorkbook.Name
    fLocation = ActiveSheet.Range("B1")
    fName = ActiveSheet.Range("b2")
    
    If Len(Dir(fLocation & fName, vbDirectory)) = 0 Then
        MsgBox Title:="Error", Prompt:="Cant find file"
        Exit Sub
    End If
    
    If Right(fLocation, 1) <> "/" Then
        fLocation = fLocation & "/"
    End If
    
    Workbooks.Open (fLocation & fName)
    
    ActiveSheet.Copy Workbooks(CurrentfName).Sheets(1)
    
    Workbooks(fName).Close False

End Sub
Attached Files
File Type: xlsm Example_Purfleet.xlsm (20.2 KB, 8 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a file to a sheet with a hyperlink? Hyperlink to open another sheet in same workbook with filtered data tarunbaweja Excel Programming 1 03-20-2016 06:52 AM
Hyperlink Format varies, depending on whether Target file was saved or unsaved on Hyperlink Copy RichardDavey Word 0 05-26-2015 05:26 PM
An error occurred while importing this file <image file> melvinjn Drawing and Graphics 1 01-19-2015 01:32 AM
Importing a file to a sheet with a hyperlink? How to set a hyperlink from a pp presentation into a CELL from an excel sheet Sabi PowerPoint 1 04-30-2013 06:36 AM
Importing a file to a sheet with a hyperlink? Importing a PST file Swoosh983 Outlook 1 08-20-2010 01:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft