+ Reply to Thread
Results 1 to 4 of 4

VBA code trouble adding variable to filepath to open copy & paste from another workbook

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    boston, ma
    MS-Off Ver
    Excel 2010
    Posts
    25

    VBA code trouble adding variable to filepath to open copy & paste from another workbook

    Hello all, I have been trying for some time now to take this code and make the *** in the file path a variable in say cell A2. As of now this code completes the task I need correctly but I would like to be able to change company data easily as all of the files are downloaded to one folder.

    Thank you in Advance for your assistance!

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: VBA code trouble adding variable to filepath to open copy & paste from another workboo

    Hi
    Change your code as follows where fName contains the first part of your file name (change to suit your needs):

    Dim wb As Workbook
    Dim fName
    fName=Range("A1").Value
    Application.ScreenUpdating = False ' turn off the screen updating
    Set wb = Workbooks.Open("C:\Users\Documents\test\" & fName & " Cash Flow.CSV", True, True)

    Hope this helps.
    Tony

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    boston, ma
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: VBA code trouble adding variable to filepath to open copy & paste from another workboo

    Tony, I cannot thank you enough, this is exactly what I was looking for!

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: VBA code trouble adding variable to filepath to open copy & paste from another workboo

    Thanks for the feedback.
    Tony

+ 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. Replies: 0
    Last Post: 07-12-2013, 05:29 PM
  2. Replies: 13
    Last Post: 11-29-2012, 08:25 PM
  3. Macro to open, copy/paste, and close files with variable name
    By mjr33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2011, 10:20 PM
  4. Replies: 4
    Last Post: 07-19-2010, 09:05 AM
  5. code for variable filepath
    By jem4614 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2008, 05:15 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