+ Reply to Thread
Results 1 to 5 of 5

Refer Folder/Filename in VBA code through Named cell reference

  1. #1
    Registered User
    Join Date
    04-15-2008
    Location
    Tamil Nadu, India.
    MS-Off Ver
    Microsoft Office 2016
    Posts
    582

    Thumbs up Refer Folder/Filename in VBA code through Named cell reference

    Dear Friends,

    I have the following codes in which I am to refer a file and folder to do some further processes.

    myfilename = "C:\Documents and settings\acs\My Documents\Entry\myfile1.xls"
    folderPath = "C:\Documents and settings\acs\My Documents\Entry\"

    I want to enter these two paths in a sheet in my excel report file (For example, I am running the report from Report1.xls, in which there is a sheet name "Filepaths". In this,

    in B5, I would like to enter the Filepath (B5 named as "FILEPATH")
    in B6, I would like to enter the Folderpath (B6 named as "FOLDERPATH")

    So that, if I am copying the folder to another area, I no need to change the code every time in the VBA editor. I can do changes in these cells and it will be taken as the path to run the code further.

    Sincerely waiting for your kind reply,

    Thanks in advance,

    acsishere.
    Last edited by acsishere; 10-31-2008 at 11:07 AM.

  2. #2
    Registered User
    Join Date
    10-25-2008
    Location
    South East Asia
    Posts
    27
    Include this code at top of the procedure
    Please Login or Register  to view this content.
    Then in the remaining statements, use the variable names fileName and folderPath. You can change variable name to your likings.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Please Login or Register  to view this content.
    or using named range

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Refer Folder/Filename in VBA code through Named cell reference

    Quote Originally Posted by XiaoWei View Post
    Include this code at top of the procedure
    Please Login or Register  to view this content.
    Then in the remaining statements, use the variable names fileName and folderPath. You can change variable name to your likings.

    Hi, how can you concatenate the folder

    I have a folder that sections change each month
    so folder path = C:\contant1\constan2\YEAR\QUARTER\constant3\

    my user would change the YEAR and QUARTER in sheet1 fields B5 & C5,

    I have seen the work sheet concatenating these into one, but cannot remember how.

    once the above script runs, I want to be left in the original file to complete the macro

    Any help, many thanks

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Refer Folder/Filename in VBA code through Named cell reference

    heathb,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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