+ Reply to Thread
Results 1 to 10 of 10

Change from IF to something else

  1. #1
    Registered User
    Join Date
    02-10-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    25

    Change from IF to something else

    Hi

    In sheet below I managing my stock levels.
    Please go to Cell F8, formula there checks In which week (red table) I will run out of my stock and tells me when I have to place new order. Example: Available stock 897400 by taking away usage from each week I will have to place order on 13/07/2015. Everything works, but.

    Question : Is there other option to get what I want without Ifs or not that many ifs.
    Thanks




    Link to file

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Change from IF to something else

    F8=lookup(sum($d8:$d8),subtotal(9,offset($j8,0,0,1,column($j8:$ba8)-column($j$8)+1)),$k$7:$bb$7)
    try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    02-10-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    25

    Re: Change from IF to something else

    Awesome!!!
    Thanks

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Change from IF to something else

    You are welcome and thanks for your feedback

  5. #5
    Registered User
    Join Date
    02-10-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    25

    Re: Change from IF to something else

    Could you please explain how does it works. Would like to understand and educate my self.

    I am so confused I just don't understand what this bit does COLUMN($J8:$BA8)-COLUMN($J$8)+1

    UPDATE: I already checked what COLUMN function does. Then I tried to copy COLUMN($J8:$BA8) in to empty cell and it gives me 10 due to J8 is 10th column, when I did the same with COLUMN($J$8)+1 it gave me 11, so 10-11 its -1, so why just not write offset($j8,0,0,1,-1 ???
    Please explain somebody

    Thanks
    Last edited by stylemonk; 02-27-2015 at 09:15 AM.

  6. #6
    Registered User
    Join Date
    02-10-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    25

    Re: Change from IF to something else

    Anyone ?

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

    Re: Change from IF to something else

    Quote Originally Posted by stylemonk View Post

    UPDATE: I already checked what COLUMN function does. Then I tried to copy COLUMN($J8:$BA8) in to empty cell and it gives me 10 due to J8 is 10th column, when I did the same with COLUMN($J$8)+1 it gave me 11, so 10-11 its -1, so why just not write offset($j8,0,0,1,-1 ???
    You have the order of calculuations wrong.
    With similar math operators (- is similar to +, * is similar to /)
    The operations are done from left to right.

    So it's not 10-(10+1) ... 10-(11)
    It's actually (10-10)+1 ... (0)+1

    And as a whole
    COLUMN($J8:$BA8)-COLUMN($J$8)+1
    The first column function creates an array of all the column numbers from J to BA {10,11,12,13,14,etc..}
    So it becomes
    {10,11,12,13,14,etc..}-COLUMN($J$8)+1
    {10,11,12,13,14,etc..}-10+1
    {0,1,2,3,4,etc..}+1
    {1,2,3,4,5,etc..}

    Hope that helps.
    Last edited by Jonmo1; 02-27-2015 at 09:35 AM.

  8. #8
    Registered User
    Join Date
    02-10-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    25

    Re: Change from IF to something else

    Quote Originally Posted by Jonmo1 View Post
    You have the order of calculuations wrong.
    With similar math operators (- is similar to +, * is similar to /)
    The operations are done from left to right.

    So it's not 10-(10+1) ... 10-(11)
    It's actually (10-10)+1 ... (0)+1

    And as a whole
    COLUMN($J8:$BA8)-COLUMN($J$8)+1
    The first column function creates an array of all the column numbers from J to BA {10,11,12,13,14,etc..}
    So it becomes
    {10,11,12,13,14,etc..}-COLUMN($J$8)+1
    {10,11,12,13,14,etc..}-10+1
    {0,1,2,3,4,etc..}+1
    {1,2,3,4,5,etc..}

    Hope that helps.
    Thanks for explanation.The problem now is how to understand formula in total in simple terms. I do apologies for not understanding and huge thank you guys for your explanations.

    OFFSET function, width() part determine the range horizontally, so if its 1 then single cell if 2 then 2 cells etc... In this case, why Column() function is used ? I mean, I could Offset(J8,0,0,1,number of cells used) but it doesn't work this way.

    Question: How this

    10,11,12,13,14,etc..}-COLUMN($J$8)+1
    {10,11,12,13,14,etc..}-10+1
    {0,1,2,3,4,etc..}+1
    {1,2,3,4,5,etc..}

    is used to get to end result?

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

    Re: Change from IF to something else

    Let's take it further

    =lookup(sum($d8:$d8),subtotal(9,offset($j8,0,0,1,column($j8:$ba8)-column($j$8)+1)),$k$7:$bb$7)
    If this part
    column($j8:$ba8)-column($j$8)+1
    becomes
    {1,2,3,4,5,etc..}
    Then the whole formula becomes
    =lookup(sum($d8:$d8),subtotal(9,offset($j8,0,0,1,{1,2,3,4,5,etc..})),$k$7:$bb$7)

    Now this creates 44 ranges by using offset
    offset($j8,0,0,1,1) = J8
    offset($j8,0,0,1,2) = J8:K8
    offset($j8,0,0,1,3) = J8:L8
    offset($j8,0,0,1,4) = J8:M8
    offset($j8,0,0,1,5) = J8:N8
    etc..

    =lookup(sum($d8:$d8),subtotal(9,{J8, J8:K8, J8:L8, J8:M8, J8:N8, etc..}),$k$7:$bb$7)

    Lets say J8:N8 = 1 2 3 4 5 respectively..
    Subtotal does the sum of visible cells, so liets say M8 is NOT visible, the rest are..
    Subtotal(9,J8) = 1
    Subtotal(9,J8:K8) = 3
    Subtotal(9,J8:L8) = 6
    Subtotal(9,L8:M8) = 6 (because M8 is not visible and ignored)
    Subtotal(9,L8:N8) = 11
    =lookup(sum($d8:$d8),subtotal(9,{J8, J8:K8, J8:L8, J8:M8, J8:N8, etc..}),$k$7:$bb$7)
    becomes
    =lookup(sum($d8:$d8),{1,3,6,6,11, etc..},$k$7:$bb$7)


    Hope that helps a bit more..

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

    Re: Change from IF to something else

    Come to think of it, the use of subtotal has nothing to do with if cells are hidden or not.
    Subtotal only ignores hidden ROWS, not columns..
    Looks like it's purpose is to create the array of results from the offset/column functions.
    Last edited by Jonmo1; 02-27-2015 at 11:41 AM.

+ 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. Need Help - Automatic website navigation page change based on column data change
    By cbatten01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-10-2015, 08:00 PM
  2. [SOLVED] How to prevent worksheet change invoking System X Control change event
    By dmw2014 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-13-2014, 10:35 PM
  3. [SOLVED] Change all matching Value based on number change in Column Excel 2007
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-20-2014, 11:40 AM
  4. Replies: 15
    Last Post: 04-17-2012, 08:19 AM
  5. auto change cell formula on condition of worksheet change in other cells
    By futurejock in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-01-2009, 12:11 AM

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