Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Excel VBA MinIfs with Array Slice

$
0
0

I am writing a code where I assign a range from a table to an 2-D array and then perform some analyses with that array. The array is of the variant type with columns 3, 4 and 5 containing the Item Name, Date and a value. The layout is similar to the following one:

Column 3    Column 4    Column 5
Item A  01/09/1987  0
Item A  01/10/1987  0
Item A  01/11/1987  1455
Item A  01/12/1987  1863
Item A  01/01/1988  1882
Item A  01/02/1988  1890
Item A  01/03/1988  0
Item A  01/04/1988  0
Item A  01/05/1988  0
Item B  01/09/1987  0
Item B  01/10/1987  2041
Item B  01/11/1987  1130
Item B  01/12/1987  1452
Item B  01/01/1988  1863
Item B  01/02/1988  1683
Item B  01/03/1988  1605
Item B  01/04/1988  1614
Item B  01/05/1988  1544

I then create a Temporary Array (the global array is way above the 65k items limit of the functions that I need) assigning the corresponding dates and values for one Item at a time. I then try using the Minifs function, as follows:

KPIMat(jCount, 3) = Application.WorksheetFunction.MinIfs( _
    Application.WorksheetFunction.Index(TempArr1, 0, 4), _
    Application.WorksheetFunction.Index(TempArr1, 0, 5), _
    ">0")

The KPIMat is an array to store the data KPI. When I run the code, I get Run-Time Error 424, Object Required message. I think it is related to the fact that the Minifs function expects a range and I am passing an 1D array. If so, has anybody come across this problem before? I have been trying to find a code-based solution, other than writing my own UDF to solve this problem.

Thanks in advance for your help


Viewing all articles
Browse latest Browse all 88854


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>