+ Reply to Thread
Results 1 to 13 of 13

Offset mixed reference formula on dynamic range

  1. #1
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Offset mixed reference formula on dynamic range

    I have a range (N6:AS6) where I search for the header "Planned". Each time I find the heading, I want to input a mixed reference formula in row 8 to 208 of that column. I have figured out how to find the header and put in the formulas, but I can't get the mixed reference part of the formula to work.

    Here is my code:

    Please Login or Register  to view this content.
    So if you look at the picture, in cell V8, it should have the formula =XLOOKUP(N$5,$N$1008:$ADB$1008,$V1011:$ADJ1011) and then in cell AG8, it should be =XLOOKUP(Y$5,$N$1008:$ADB$1008,$V1011:$ADJ1011). So I'm not getting the dynamic column part to work. What am I missing?

    Screenshot 2021-09-29 172021.jpg
    Attached Files Attached Files
    Last edited by PingTing; 09-29-2021 at 05:47 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    Not sure what you'r expecting from us here. A picture is not generally very helpful BUT if you are going to post a picture it would be useful to make it a size that we can actually read.

    Please see the yellow banner at the top of the page.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    Sorry Trevor. I have attached sample workbook now. Thanks.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    Thanks, Trevor. That worked perfectly. One question - I see you commented out the n in "Next 'n". Did you mean to do that or was that a mistake? It worked with it commented out though.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    You're welcome. Thanks for the rep.

    I see you commented out the n in "Next 'n".
    Yes. You don't actually need to specify the variable on the Next statement. You can just use "Next" . And I seem to recall reading somewhere, sometime, a long time ago, that it was more efficient to leave it out. By commenting it out, you have the best of both worlds; efficiency plus you still have a reference for the loop.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  7. #7
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    Marked as Solved. Thanks again. Just brilliant!!!

  8. #8
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    One thing, Trevor. How do I run it from another sheet? In my working workbook, I have to run it from a different sheet (via a button).

    So in my test book attached here, I tried adding Sheet1 to all the ranges, and then running it from Sheet2. But then it didn't work. How can I get around that?

    Here's the code now;

    Please Login or Register  to view this content.
    I get the error "Run-time error '1004': Method 'Range' of object '_Worksheet' failed"
    Attached Files Attached Files

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    I'm not in a position to look at the workbook or test your code. However, it may help to change this:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Note that Sheet1 is not necessarily the same as Sheets("Sheet1")

  10. #10
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    Thanks, Trevor. Worked perfectly again. But then a new error came up (only in the working workbook).

    I got the error "Run-time error '1004': Application-defined or object-defined error".

    Am I missing something again?

    Test workbook code where everything works fine (runs from either sheet):

    Please Login or Register  to view this content.
    Working workbook code (doesn't work at all):

    Please Login or Register  to view this content.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    You've added an extra IF to the formula. It looks, to me, as if it's missing a close bracket at the end (before the double quotes). Does it compile?

  12. #12
    Registered User
    Join Date
    09-08-2018
    Location
    Kamloops, Canada
    MS-Off Ver
    Office 365
    Posts
    86

    Re: Offset mixed reference formula on dynamic range

    Well then. Don't I feel like an idiot... So embarrassing. Thanks, again. This has been such a great help.

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Offset mixed reference formula on dynamic range

    Don't I feel like an idiot...
    You may think/say that, I could not possibly comment.

+ 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. Excel formula to replace range reference with dynamic range
    By mp3909 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-12-2021, 03:32 PM
  2. [SOLVED] Using Dynamic reference in OFFSET
    By DOIE in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-04-2019, 09:53 AM
  3. Replies: 1
    Last Post: 04-15-2019, 12:14 AM
  4. [SOLVED] Creating the OFFSET formula with a dynamic reference cell
    By jmillikan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-21-2015, 04:05 PM
  5. Replies: 1
    Last Post: 04-10-2015, 11:53 AM
  6. Is it possible to reference a dynamic range in a lookup formula?
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 14
    Last Post: 01-11-2014, 04:47 PM
  7. Dynamic Reference with Offset
    By cooly53 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2013, 12:25 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