+ Reply to Thread
Results 1 to 7 of 7

Using dynamic file path instead of hard-coded

  1. #1
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Using dynamic file path instead of hard-coded

    Hi

    I am teaching myself VBA coding so hopefully my title and what I want to do make sense.

    I have spent a lot of hours searching, testing etc but I am a bit stumped on this one. If someone could have a quick look and point me in the right direction it would be greatly appreciated.

    I have two workbooks that will live in different folders, in this case TEST and TEST2.

    In folder TEST I have a workbook named DRAWING REGISTER with data in the range A2 to B800, Column A is the drawing number and column B is the revision number.

    I want to copy this data from this worksheet into another worksheet named DRAWING STATUS in the TEST 2 folder which at present I have hard-coded into the code I have so far.

    Please Login or Register  to view this content.
    I would like to have cell A2 in worksheet COMP (current data in that cell is 'C:\Users\Melly\Desktop\Test\Drawing Register.xlsx') in the VBA code to replace the hard-coded path. That way I can just replace the path to cell A2 and it will automatically update to the new path.

    Two minor details I would like to address is when the DRAWING INDEX closes, I get a message asking if I want to save any changes, which I do not, as I am only pulling data from that worksheet.

    The other is a message asking if I would like to keep the large amount of data on the clipboard, which once again I do not.

    Hopefully I have explained well enough to get some help.

    Thanks in advance, Anthony

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Using dynamic file path instead of hard-coded

    for the closing of the workbook have you tried
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Using dynamic file path instead of hard-coded

    How about
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Re: Using dynamic file path instead of hard-coded

    I have tried to add the two files as attachments but I think I fried my brain getting to where I did

    If necessary I will try again after a bit of a break.

    Hopefully someone smarter than me can decipher my questions above without them.

  5. #5
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Re: Using dynamic file path instead of hard-coded

    Legend, worked exactly as intended.

    Greatly appreciate the help.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Using dynamic file path instead of hard-coded

    Glad we could help & thanks for the feedback

  7. #7
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Re: Using dynamic file path instead of hard-coded

    Sorry, I didn’t see your suggestion before I went ahead with Fluff13s solution below. Appreciate you taking time to help.

+ 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. [SOLVED] Make a Simple Formula With Hard Coded Values Dynamic
    By NeedForExcel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-17-2017, 02:49 AM
  2. [SOLVED] I need a macro to open a file, but I don't want to hard code the path.
    By armlegx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2016, 11:56 PM
  3. Where to store data - hard coded or in an external file
    By KevBotes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2016, 01:45 PM
  4. [SOLVED] Excel VBA: changing hard coded column to dynamic range to autofill to last row
    By AishaSanz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2014, 11:40 AM
  5. [SOLVED] Is it possible to replace this hard coded file name with a constant or variable?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2013, 11:21 PM
  6. consolidating excel files into one file not using hard code of folder path
    By rrakkki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2011, 09:05 AM
  7. Hard code path to refresh data from a csv file
    By R.Baxter in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-03-2009, 09:33 AM

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