+ Reply to Thread
Results 1 to 19 of 19

Cannot use INDIRECT in the following formula

  1. #1
    Registered User
    Join Date
    01-09-2004
    Location
    Toronto
    Posts
    6

    Cannot use INDIRECT in the following formula

    I have the following formula that works very nicely. It finds the column number of the first value greater than 0 going from right to left in the range.

    =LOOKUP(2,1/(MASTER_PLAN!C3:BZ3>0),COLUMN(MASTER_PLAN!C3:BZ3))

    I would like to use an INDIRECT in place of the first range. If I use it in the second range only, it works. if I use it in the first, I get an error.

    Ideas?


    Thanks in advance!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    Can you post what you tried that didn't work?
    And describe which parts of the original formula are being replaced with cell references?

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Cannot use INDIRECT in the following formula

    Hi,

    Would you share with us the formula with the Indirect that you are trying?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Cannot use INDIRECT in the following formula

    In what way are you wanting to use INDIRECT? Picking up the sheet name from another cell, or what?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    This works fine for me with the sheetname (MASTER_PLAN) written in A1

    =LOOKUP(2,1/(INDIRECT("'"&A1&"'!C3:BZ3")>0),COLUMN(INDIRECT("'"&A1&"'!C3:BZ3")))

  6. #6
    Registered User
    Join Date
    01-09-2004
    Location
    Toronto
    Posts
    6

    Re: Cannot use INDIRECT in the following formula

    The following returns the range properly.

    INDIRECT("MASTER_PLAN!C"&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN)))&":"&IF(COLUMN(INDIRECT(AH5))-1<=26,CHAR(COLUMN(INDIRECT(AH5))-1+64),CHAR(INT((COLUMN(INDIRECT(AH5))-1-1)/26)+64)&CHAR((MOD(COLUMN(INDIRECT(AH5))-1-1,26))+65))&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN))))

    FYI - FINDIT is a user defined function that I found online. It returns a cell address

    So if I take the above and paste into the latter part of the above formula:

    =LOOKUP(2,1/(MASTER_PLAN!C3:BZ3>0),COLUMN(INDIRECT("MASTER_PLAN!C"&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN)))&":"&IF(COLUMN(INDIRECT(AH5))-1<=26,CHAR(COLUMN(INDIRECT(AH5))-1+64),CHAR(INT((COLUMN(INDIRECT(AH5))-1-1)/26)+64)&CHAR((MOD(COLUMN(INDIRECT(AH5))-1-1,26))+65))&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN))))))

    I get the desired result "65"

    When I use the same INDIRECT and replace the first range i always get an error. (That happens whether the INDIRECT is used or nor for the second half of the formula.

    =LOOKUP(2,1/(INDIRECT("MASTER_PLAN!C"&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN)))&":"&IF(COLUMN(INDIRECT(AH5))-1<=26,CHAR(COLUMN(INDIRECT(AH5))-1+64),CHAR(INT((COLUMN(INDIRECT(AH5))-1-1)/26)+64)&CHAR((MOD(COLUMN(INDIRECT(AH5))-1-1,26))+65))&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN))))>0),COLUMN(INDIRECT("MASTER_PLAN!C"&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN)))&":"&IF(COLUMN(INDIRECT(AH5))-1<=26,CHAR(COLUMN(INDIRECT(AH5))-1+64),CHAR(INT((COLUMN(INDIRECT(AH5))-1-1)/26)+64)&CHAR((MOD(COLUMN(INDIRECT(AH5))-1-1,26))+65))&ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN))))))

    I get #N/A

    The original working query:

    =LOOKUP(2,1/(MASTER_PLAN!C3:BZ3>0),COLUMN(MASTER_PLAN!C3:BZ3)) Result is 65

    Thanks

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Cannot use INDIRECT in the following formula

    Likewise, except that I put it in B7!!

    =LOOKUP(2,1/(INDIRECT("'"&B7&"'!C3:BZ3")>0),COLUMN(INDIRECT("'"&B7&"'!C3:BZ3")))

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Cannot use INDIRECT in the following formula

    OMG!!! No-one is going to want to try to wade their way through that lot without seeing it in context!! Please attach a sample workbook. Make sure there is enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary. Remember to remove ALL confidential information first!!!

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  9. #9
    Registered User
    Join Date
    01-09-2004
    Location
    Toronto
    Posts
    6

    Re: Cannot use INDIRECT in the following formula

    Sorry. Sure Thing

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Cannot use INDIRECT in the following formula

    What is this rather (!!) complicated formula trying to do for you?

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    Wow, That's quite a formula there. There's probably a much easier way.
    Honestly, you probably don't need indirect to begin with.

    You pretty much only need indirect when it's the Sheet's NAME that needs to be varied by a cell reference.
    But it seems in reality you want to vary the beginning and ending Columns to do the lookup with.
    Right?

    Can you describe with words, how this part
    ROW(INDIRECT(FINDIT(LEFT(T5,5),TRAILER_PLAN)))
    Finds the beginning Column letter?
    Perhaps share the code for the FINDIT udf, and what is Trailer_Plan.. A named range?

    And what exactly is in AH5, how does that help to find the last column ?

  12. #12
    Registered User
    Join Date
    01-09-2004
    Location
    Toronto
    Posts
    6

    Re: Cannot use INDIRECT in the following formula

    FINDIT is
    Function FINDIT(v As Variant, r As Range) As String
    FINDIT = ""
    For Each rr In r
    If rr.Value = v Then
    FINDIT = rr.Address
    Exit Function
    End If
    Next
    End Function

    The beginning column letter is always "C". I then find the last column before the next truck departure. CA3SCHEDULE.png
    The yellow in the picture is 0 and the green are 1. In the long run I am trying to look up the time from the last one before the next departure. That's why I go from right to left.

    AH5 which equals CA3 is cell where the next truck is departing.
    Last edited by DJ_DEF; 06-02-2015 at 11:00 AM.

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Cannot use INDIRECT in the following formula

    Nice, but where's the spreadsheet?

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    Is CA3 manually typed into AH5, or is that a formula as well?
    If it's a formula, what's that formula?

    This is leading somewhere, so go with it..


    And an actual workbook would be nice as Glenn said.

  15. #15
    Registered User
    Join Date
    01-09-2004
    Location
    Toronto
    Posts
    6

    Re: Cannot use INDIRECT in the following formula

    EQUIPMENT_UTILIZATION_SAMPLE.xlsm

    The file is attached. I removed nearly everything to get it down to the right size.

    Thanks again.

  16. #16
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    OK, i think a completely new approach is called for here.

    Is the overall goal to make a range that is on the row where Findit finds the value.
    And begins in column C and ends in the last column <>0 of that row found by findit?

    Then use that range in the initial lookup formula
    =LOOKUP(2,1/(MASTER_PLAN!C3:BZ3>0),COLUMN(MASTER_PLAN!C3:BZ3))

    Is that about right?

  17. #17
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    Here's a stab...

    Change your FINDIT Code to
    Please Login or Register  to view this content.
    Then use
    =LOOKUP(2,1/(MASTER_PLAN!C3:FINDIT(LEFT(T5,5),TRAILER_PLAN)>0),COLUMN(MASTER_PLAN!C3:FINDIT(LEFT(T5,5),TRAILER_PLAN)))

  18. #18
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    Correction, the formula would be

    =LOOKUP(2,1/(INDEX(MASTER_PLAN!$C:$C,ROW(FINDIT(LEFT(T5,5),TRAILER_PLAN))):FINDIT(LEFT(T5,5),TRAILER_PLAN)>0),COLUMN(INDEX(MASTER_PLAN!$C:$C,ROW(FINDIT(LEFT(T5,5),TRAILER_PLAN))):FINDIT(LEFT(T5,5),TRAILER_PLAN)))

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Cannot use INDIRECT in the following formula

    You're welcome.
    And thanks for the Credit.

+ 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. [SOLVED] INDIRECT Function with multiple sheets - SUMIF, INDIRECT & MATCH
    By DJDRU in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-07-2014, 08:42 AM
  2. adding Indirect formula to my current sum if array formula
    By Eastbay2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-13-2013, 09:41 AM
  3. Sum of indirect sheet names with multiple cells (SUM, INDIRECT,SHEETNAME in cell)
    By a1b2c3d4e5f6g7h8 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-12-2013, 08:42 AM
  4. Replies: 1
    Last Post: 02-10-2012, 02:53 AM
  5. Allow EXCEL INDIRECT(ADDRESS()) and INDIRECT(RANGE()) functions
    By Mike Barlow in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 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