+ Reply to Thread
Results 1 to 5 of 5

How do I assign a selected range to a name in VBA that updates everytime macro is run

  1. #1
    Registered User
    Join Date
    09-30-2012
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    3

    How do I assign a selected range to a name in VBA that updates everytime macro is run

    When I record a macro to set a name to a selection it sets the name to a A1C4 type reference (or whatever I have selected). Next time I run teh macro it sets the name to the same range and not the new selction.
    I can't find the method that extracts the reference from the selection and can be assigned to name.

  2. #2
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: How do I assign a selected range to a name in VBA that updates everytime macro is run

    The same name cannot be added to two ranges. In the code, you have to edit the reference of the named range.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-30-2012
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How do I assign a selected range to a name in VBA that updates everytime macro is run

    I don't have the reference, I just have a selection

  4. #4
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: How do I assign a selected range to a name in VBA that updates everytime macro is run

    I understand from your post that you had named a range using vba code. And you are trying to add a different range with the same name. I gave the solution for that only. Let me know if my understand is wrong.

  5. #5
    Registered User
    Join Date
    09-30-2012
    Location
    New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How do I assign a selected range to a name in VBA that updates everytime macro is run

    I found the answer thanks

    Please Login or Register  to view this content.
    What I was struggling with was assinging a range to a name that was different each time the macro ran
    Last edited by jeffreybrown; 10-05-2012 at 09:59 PM. Reason: Please use code tags. Thanks.

+ 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