+ Reply to Thread
Results 1 to 11 of 11

Relative References Named Ranges

  1. #1
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Relative References Named Ranges

    Hi, I am having trouble pushing a formula to cell and maintaining my exact relative reference; please help if possible. For some reason it keeps referring to U$12 rather than K$12. I'm not sure RefersToRange helps. Thanks for your help


    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Relative References Named Ranges

    I suggest that you:
    1. Post actual code in future.
    2. Use R1C1 references, then you won't have to activate anything.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    Quote Originally Posted by romperstomper View Post
    I suggest that you:
    1. Post actual code in future.
    2. Use R1C1 references, then you won't have to activate anything.
    I would love to unfortunately it's part of a larger set of code that I cannot post here. I'm not sure how to do what you're saying with R1C1 though?

    Also, are we saying it's not possible to capture the correct reference with A1? Everything else is working it's just giving me a "random" U reference instead of K

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Relative References Named Ranges

    But what you posted wouldn't even have compiled.

  5. #5
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    Quote Originally Posted by romperstomper View Post
    But what you posted wouldn't even have compiled.
    Please Login or Register  to view this content.
    it compiles, this is a piece of code that adds the name, sorry, just looking for clarification what you need to help me, because I am in need of help sir. I just cannot put the whole sub. on here

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Relative References Named Ranges

    That first line could not possibly compile.

    I'd need to know what the other variables are because they will likely need converting to R1C1 format as well.

  7. #7
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    Quote Originally Posted by romperstomper View Post
    That first line could not possibly compile.

    I'd need to know what the other variables are because they will likely need converting to R1C1 format as well.
    It compiles.

    Line 1: declares static variable but is just K$12

    Line 2: GoTo cell

    Line 3: adding Named Range Formula; incorrectly referring to U$12 instead of K$12

    Line 4: nonsense, removed
    Last edited by cmore; 02-04-2015 at 04:43 PM.

  8. #8
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    So I found it (a little), basically when you do this weird relative thing, you have to add the relative formula with an Range("A1") basis if that makes any sense

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Relative References Named Ranges

    Again, there is no way that compiles. You can't declare and assign a variable in one line in VBA, and the variable is clearly a string so its value should be in quotes. Anyway, irrelevant now but in future it would be better to post the actual relevant lines of code otherwise people trying to help you will be confused and distracted by code issues that don't actually apply, rather than trying to address your issue.

  10. #10
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    Ha, you're right, sorry about that, I didn't even realize I ddin't copy the whole declaration
    Please Login or Register  to view this content.
    the variable is left as variant. I 100% understand what you're saying and see how it can be distracting.

  11. #11
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Relative References Named Ranges

    Quote Originally Posted by cmore View Post
    Ha, you're right, sorry about that, I didn't even realize I ddin't copy the whole declaration
    Please Login or Register  to view this content.
    the variable is left as variant. I 100% understand what you're saying and see how it can be distracting.
    So what I ended up doing for this is, I add an offset formula to update the formula based on the cell's location. I don't think this is optimal though, because I have to use offset and address (volatile) in several cells. I am also taking your suggestion of converting formulas to R1C1 and then pushing them to the named range also (application.convertformula). I have to convert them because the formulas are a user input.

    Still wondering if there's a better way to do this

+ 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. Relative references to named range
    By Pete in forum Excel General
    Replies: 6
    Last Post: 12-09-2013, 06:25 PM
  2. Relative Named Ranges in Excel
    By gillywilly in forum Excel General
    Replies: 1
    Last Post: 09-18-2007, 11:56 AM
  3. Relative Autofilter using Named Ranges
    By BA99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2007, 06:34 PM
  4. Named formulas in CHOOSE need to be Relative references when paste
    By bill ch in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-10-2006, 11:20 AM
  5. [SOLVED] Confused about relative references in named formulas
    By davidmichaelkarr@gmail.com in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-22-2006, 06:45 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