+ Reply to Thread
Results 1 to 10 of 10

Using Range Name reference as part of R1C1 Formula

  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Using Range Name reference as part of R1C1 Formula

    Greetings:

    Am currently using the code, shown below.
    This worked great until I started using my macro multiple times on one sheet
    and multiple times within one workbook.
    Obviously, only One cell can be called "NoOfUnits".
    All further references to that range name ends up useing the original result.

    Please Login or Register  to view this content.
    1: How can I best get around this problem?
    2: I can place the formula result that is in the cell called NoOfUnits in a fixed location - Say Z5.
    Is there a way to mix and match R1C1 type references with standard A1 type references?
    For example ( however, this does not work)

    Please Login or Register  to view this content.
    Thank-you

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Using Range Name reference as part of R1C1 Formula

    You can mix them to do what you are after however the syntax is a little different
    Please Login or Register  to view this content.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    Smuzoen
    Thanks for the response.
    I'm getting an error with this method: Run-time error 1004; Application-defined or object-defined error.
    I have no idea where (or how) to start looking for this.
    Pls. advise..........

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Using Range Name reference as part of R1C1 Formula

    I'm not sure I follow what the problem is. Why can't you use a named range to refer to one cell?
    Also you appear to be missing a column reference in your original formula which I suspect should refer to R[-1]C rather than just R[-1]

    FWIW, $Z$5 in R1C1 notation is R5C26
    Good luck.

  5. #5
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    Thanks for the response.
    My original code, as shown, worked just fine, for a long time already.
    However, I am now expanding the use of the code.
    It will now be used multiple times within the same workbook.
    Once the named range is set, it holds it for all future references within that book.
    Consequently, my calculations are out to lunch.

    If there is another way of tackling this, that would be OK, as well.
    Keep in mind that the numbers of rows involved each time, will vary.

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Using Range Name reference as part of R1C1 Formula

    1. Your original formula is still wrong, even if it happens to work.
    2. You should be using formular1c1 not formula - later versions of excel are not as forgiving.
    3. That still doesn't explain why you can't use a named range since you appear to want to refer to one specific cell.
    4. It also doesn't address my last point which showed how to refer to Z5.
    5. Phrases like "out to lunch" or "doesn't work" do not help us to help you. We always need more specific information than that.

  7. #7
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    1: You are absolutely correct, of coarse. Statements shouldn't be 'shortened', as mine was.
    No doubt some future version will take exception to what today does work.
    I'll pass that on to the guru who initially supplied me with this code.
    2: As above
    3: Named Range. EACH time the macro is run, it is applied to a different data base, with a different number of rows, within the same workbook. Consequently, the formulas do NOT work correctly, since it appears to always reference the original (first) named range.
    For example, if the first time I run the macro it indicates that there are 10 rows in use, that is what the named range will refer to.
    The next the macro is run, the data could consist of 250 rows, yet this formula will be dividing 10, not by 250, as required.
    I hope that makes it a bit clearer.
    4: Sorry! I did try R5C26 with and without quotes.
    With quotes I get run time error 1004; Method 'Range' of object'_Global' failed.
    Without quotes I get Compile Error: Variable not Defined
    5: I hope the above clears this one up.

    The following shows the macro in question, without all the duplicates used to operate on the multiple columns.
    Perhaps that might also help clear up what I'm obviously not expressing very well or perhaps you might see what in my code is perhaps tripping me up.
    Thanks for your consideration.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    Greetings All:

    Since we collectively are unable to come to a working solution at this time,
    I've tackled the situation the long way round.
    The code I've used is shown below, together with some comments.
    I hope that this may still help someone else out.

    So, I guess you could say that, while this thread had not been solved, the
    situation has been 'resolved'.

    Thanks for all the efforts.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    Yes I did.
    NoOfUnits, as indicated in initial post is a range name.
    I could not get your best guess to work - Sorry.

  10. #10
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Using Range Name reference as part of R1C1 Formula

    That was exactly the case.
    However, your best guess DOES NOT WORK!!!
    It was one of the first efforts I made myself before ever posting, along with dozens of other tries.
    Maybe the problem has to do with the fact that I'm still running Excel 2003. ???
    I appreciate your efforts, but guessing has to stop at some point.

    Over and out.

+ 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