'min & max value in range in loop

I've faced huge problem with my macro. I have data that contains colums with quantities and values of stock like this:

enter image description here

What I'm trying to achieve is:

  1. to go through every row until the very last, locate quantity (colums with Q letter) and values (colums with V letters) below 0, then adding these quantities below zero to the maximum quantity within the row and adding these values below 0.
  2. to find values within age category for every row that have no corresponding quantity (see cell B4 as example) and add these values to the maximum value within the row.


Solution 1:[1]

Why VBA for something you can achieve with a formula?

Let me show you how I calculate the maximum of a list of cells, referring to a column, whose name starts with a "V":

=MAXIFS(A2:F2,A1:F1,"V*")

Screenshot:

screenshot

Explanation:

  • Take the maximum of the values on the second row (A2:F2)
  • The criteria you need to take into account refer to the first row (A1:F1)
    • The criteria is that it should start with a "V".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dominique