+ Reply to Thread
Results 1 to 2 of 2

ChDir linked to file address in cell

Hybrid View

  1. #1
    Registered User
    Join Date
    08-07-2019
    Location
    Scotland
    MS-Off Ver
    2016
    Posts
    56

    ChDir linked to file address in cell

    Hey Guys,

    Hoping someone can help me out, I have a file use to pull in data for me from various sources I am trying to get it so other people can use it as well to help them out to not have to manually pull in data.

    However when ever i try to link the ChDir to the file location on the SetUp tab cell B3. Could someone help me out with the code to open and repair the file in Sheets("Set Up").Range("B3")

    Sub OpenZproj()
    '
    ' OpenZproj Macro
    ' Open Zproj file saved from SAP and copy into the sheet
    '
    Dim sPath As String, sFile As String
    Dim oWB As Workbook
        sFile = Sheets("Set Up").Range("B3").value
    'On Error GoTo Err_Open
    
    Sheets("ZPROJ").Select
        Cells.Select
        Application.CutCopyMode = False
        Selection.ClearContents
     
        ChDir "C:\Users\Kyddgorg\Desktop\SAP Reports"
        Set oWB = Workbooks.Open(sFile, CorruptLoad:=XlCorruptLoad.xlRepairFile)
        Range("A1").Select
        Selection.CurrentRegion.Select
        Selection.Copy
        Windows("Cost Tracker Wizard.xlsm").Activate
        Cells.Select
        ActiveSheet.Paste
        Windows("zproj.xlsx").Close
    
    
    
    Exit Sub

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: ChDir linked to file address in cell

    In place of ChDir, possibly using...
        sFile = Environ("UserProfile") _
                & "\Desktop\SAP Reports" _
                & Application.pathseparator _
                & Sheets("Set Up").Range("B3").Value

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy a sheet to another Excel file (file name linked to the cell)
    By wess2016 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2019, 02:32 AM
  2. [SOLVED] checkbox linked cell address - display only row number
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2018, 06:57 AM
  3. Writing formula with copying another address linked in a cell
    By ngngc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-18-2016, 03:03 PM
  4. Radio Buttons in Excel 2007 automatically lose the linked cell address
    By tnkchari in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 11:45 AM
  5. [SOLVED] sum(offset(... to linked file requires linked file to be open?
    By Oppressed1 in forum Excel General
    Replies: 5
    Last Post: 10-22-2012, 02:21 PM
  6. Reference checkbox using linked cell address
    By chewie in forum Excel General
    Replies: 3
    Last Post: 06-02-2011, 02:11 PM
  7. [SOLVED] Find linked cell address
    By shirleyxls in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2011, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1