+ Reply to Thread
Results 1 to 8 of 8

Max of row based on pre-set dynamic conditions

  1. #1
    Registered User
    Join Date
    07-18-2017
    Location
    Dubai
    MS-Off Ver
    2016
    Posts
    7

    Max of row based on pre-set dynamic conditions

    Hi guys,

    I have a slightly complicated issue that I need help with automating. The sheet I’m referring to is attached with this post.
    Basically, I have a table comprising cells B2:T26 and I need to retrieve values in the adjoining table under column W (Incremental Amount).

    However, the values that I need to retrieve will vary from row-to-row according to the below:
    • The value in W4 is the max of cells C4:T4 ie “78” (D4)
    • The value in W5 is the max of cells (C4,E4:T4,D5) (since D4 has already been retrieved in step 1. This value is retrieved as “77” (D5)
    • Similarly, the value in W6 is the max of cells (C4, E4:T4,D6) (since D4 and D5 have already been retrieved in step 1 and step 2 respectively. This value is retrieved as “89” (D6)
    • The above steps will continue, and at each step, the first value in each column should be considered in the MAX formula unless it has already been utilized, in which case the next cell should be considered.
    Please see the formulae in cells W4:W195 incase this isn’t clear.
    At some point, there may be 2 or 3 values which would each fulfill the MAX criteria. In this case, we need to prioritize in ascending order (ie Item A over Item B over Item C…..)

    Once this has been done, we then need to identify the cell address corresponding to the values retrieved in column W. Or alternatively retrieve the Item , Type and Value for this cell. (Perhaps this could be included in the formula??)
    I’ve been doing this manually till now, but see that there could be some element of automation to this.

    Any help with a formulae or some VBA script would be appreciated?
    Attached Files Attached Files
    Last edited by darrenpinto; 07-18-2017 at 04:49 AM. Reason: Title Change - Adding more details

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Max of row based on pre-set dynamic conditions

    Please Login or Register  to view this content.
    RUN button to execute macro

    Results in column AA and AB

    NOTE: there is currently no check for duplicates.

    QUESTION: What is test for "completion": macro current executes the rows you have determined i.e finishes on row 171
    Attached Files Attached Files
    Last edited by JohnTopley; 07-18-2017 at 07:55 AM.

  3. #3
    Registered User
    Join Date
    07-18-2017
    Location
    Dubai
    MS-Off Ver
    2016
    Posts
    7

    Re: Max of row based on pre-set dynamic conditions

    Hi John,

    Really appreciate your help.

    Regarding the duplicates query, as mentioned, there may be 2 or 3 values which would each fulfill the MAX criteria. In this case, we need to prioritize in ascending order (ie Item A over Item B over Item C…..). Has this been layered in already? If not, is it possible to?

    Regarding completion, the sheet sent was a template. We would ideally ideally like it to be complete upon the sum of the values in column Z = 80,000
    In other words, it will 800 iterations.

    Hope this is clear, and thanks again for your help.

    Darren


    NOTE: there is currently no check for duplicates,
    QUESTION: What is test for "completion": macro current executes the rows you have determined i.e finishes on row 171

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Max of row based on pre-set dynamic conditions

    How do you calculate the "VALUE" in column Z or is it just a constant of 100? and I assume "TYPE" correlates to the "Cell Address"

    And can you post a file with one (or more) duplicates (preferably near the beginning of the data to help make testing easier!)

    And it is not clear how to can do 800 iterations when you have < 500 cells?

    What happens when we reach row 26 for any column?

    Attached is an example of simply looping 800 times: I deleted the erroneous value resulting form values in rows > 26
    Attached Files Attached Files
    Last edited by JohnTopley; 07-18-2017 at 11:31 AM.

  5. #5
    Registered User
    Join Date
    07-18-2017
    Location
    Dubai
    MS-Off Ver
    2016
    Posts
    7

    Re: Max of row based on pre-set dynamic conditions

    Hi John,

    Really appreciate your help.

    You can disregard the previous request. I solved it by changing the row value in the macro you assigned.

    Is it possible to add a layer where the value returned in column AA corresponds to the letters in the column (A, B, C), and returns that letter?

    This will involve HLookup formula I'm assuming? Would you be able to share the formula?

    Thanks again!

    Darren

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Max of row based on pre-set dynamic conditions

    Unmerge headings in row 2 and in AC4

    =INDEX($A$2:$T$2,COLUMN(INDIRECT($AB4)))

    Copy down

  7. #7
    Registered User
    Join Date
    07-18-2017
    Location
    Dubai
    MS-Off Ver
    2016
    Posts
    7

    Re: Max of row based on pre-set dynamic conditions

    Thanks John

    Appreciate the help!

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Max of row based on pre-set dynamic conditions

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. IE automation
    By bradl822 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2015, 05:00 AM
  2. [SOLVED] Please help with IE automation by VBA
    By vpnvipin in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-09-2013, 09:07 AM
  3. IE Automation
    By hodpy62 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2009, 01:10 PM
  4. Automation using VBA
    By kingfisher007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2008, 07:29 AM
  5. Automation
    By Brian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2006, 12:10 PM
  6. Automation
    By crowngab in forum Excel General
    Replies: 1
    Last Post: 06-15-2005, 07:05 AM
  7. Automation
    By Chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2005, 03:06 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