+ Reply to Thread
Results 1 to 4 of 4

Using the Name Manager with VBA

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Using the Name Manager with VBA

    Question: Is there a way to declare/edit names using VBA?

    Specifics (Unnecessary maybe? But they're here anyway if you need to understand better what I'm talking about):

    I have two workbooks. One (we'll call "Main.xlsx") looks up information in the other (we'll call "Database.xlsx"). To do this, I created a name, "Database," (via the Name Manager, Ctrl+F3) that refers to the "Database" table within my "Database.xlsx" workbook. I use Main.xlsx as a template, and I create copies of this workbook and use them for different things and save them in different locations. However, all of these copies refer to my one "Database.xlsx" workbook.

    There are two issues I'm trying to deal with.

    First, when I save my "Main.xlsx" template and "Database.xlsx" in the same folder, the reference becomes a relative filepath instead of absolute (i.e. excel assumes that those two workbooks will always be in the same folder). To get around this, I just saved Main and Database in two separate folders, which is not ideal. If there's a way to edit the name references with VBA, I wouldn't have a problem fixing it.

    Second, I plan on passing these workbooks onto other people. As it is now, my name references use absolute filepaths for my own computer. I would like to make it so they wouldn't have to manually edit the filepath using the Name Manager. Again, I could solve this problem if there were a way to edit those name references using VBA.

    Thanks so much
    Last edited by iamtehwalrus; 04-16-2010 at 12:28 AM.

  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Using the Name Manager with VBA

    hi,

    Yes, Names can be added, manipulated, & deleted in VBA. Do you have experience in using macros?

    If not, let us know & we can be more detailed in our explanations.
    If so, try recording a macro of your actions when you make changes to a name manually, then post your recorded code & we can help make it more generic. Note, if you are going to have macros in your file, you need to save it in a different file format than .xlsx, for example save as ".xls" or ".xlsm".

    Here are some links which may be of interest...
    - NBVC's suggestions in http://www.excelforum.com/excel-prog...-row-cell.html
    - explanation of how excel saves info relating to external links (see the UNC path section) http://support.microsoft.com/kb/328440

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  3. #3
    Registered User
    Join Date
    03-13-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using the Name Manager with VBA

    Thanks, that was helpful. As it turned out, I had tried this before, but my syntax was off and/or I put the code in the wrong part of my sub so it never actually executed while I was testing it. And you're right, I mistakenly said Main.xlsx when I meant Main.xlsm

    That solved my problem. Thanks so much

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Using the Name Manager with VBA

    I'm pleased I could help - thanks for adding to my rep' & marking the post as Solved

+ 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