Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
Its been a while since i have been on here so VB getting a little rusty, anyway hoping one of you Guys will be able to use your vast knowledge to help me resolve the following. I have created a spreadsheet to monitor the results of some testing i am doing, however only want to show the Maximum, minimum and average results of those results that have passed. Now as it states in the header i can achieve this via using the following excel formulas on the spreadsheet. {=IF(MIN(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)))=0, "ND",MIN(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)) ))} {=IF(MAX(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)))=0, "ND",MAX(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)) ))} {=IF(MIN(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)))+MA X(IF(IF($C:$C="PASS",IF($A:$A="VP",$C:$C)))=0,"ND" ,AVERAGE(IF($C:$C="PASS",IF($A:$A="VP",$C:$C))))} ColA ColB ColC Build Reading Result VP 6.5 PASS VP 5.8 PASS VP 1078 FAIL VP 260 FAIL VP 117 FAIL VP 115 FAIL VP 224 FAIL VP 15.2 PASS The problem is that there are there are many different permatations due to the differing builds as well as the other condition that the test subject can be in (approx 50 permatations in all) so Excel does not have the memory capacity to achieve this, hence the reason i suspect using a dynamic array and VB code would be better as it is hoped that it can do the calculation, populate the spreadsheet with the value, erase the array and move onto the next calculation until all values are in. Anyway as stated it has been since i played with VB, so in all honesty don't even know were to start, however think once i get sorted with the first set of calculations then i shoul be ok. Thus any help would be greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perhaps something less complex and more 'maintenance friendly'...
Sub Test2() Dim vDataIn, vDataOut(), n&, j&, k& Dim lRows&, lCols&, s1$ With Sheets("Sheet1") lRows = .Cells(Rows.Count, 1).End(xlUp).Row vDataIn = .Range("A2:C" & lRows) End With 'Sheets("Sheet1") s1$ = "(IF((A2:A" & lRows & "=""" & vDataIn(n, 1) & """)*(C2:C" _ & lRows & "=""" & vDataIn(n, 3) & """),B2:B" & lRows & "))" ReDim vDataOut(UBound(vDataIn) * UBound(vDataIn), 8) For n = LBound(vDataIn) To UBound(vDataIn) For j = LBound(vDataIn) To UBound(vDataIn) k = k + 1 vDataOut(k, 1) = vDataIn(n, 1) vDataOut(k, 2) = vDataIn(n, 3) vDataOut(k, 3) = "Min" vDataOut(k, 4) = Evaluate("=MIN" & s1) vDataOut(k, 5) = "Max" vDataOut(k, 6) = Evaluate("=MAX" & s1) vDataOut(k, 7) = "Avg" vDataOut(k, 8) = Evaluate("=AVERAGE" & s1) Next 'j Next 'n lRows = UBound(vDataOut): lCols = UBound(vDataOut, 2) Sheets("Sheet1").Range("G1").Resize(lRows, lCols) = vDataOut End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
@ Garry:
You can't initialize a string with variables when these are not yet initialized. You will get a runtime error.The formula string must be placed into the loop. Yes, yes.., nice catch! I pasted in the wrong place... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
corrected version...
Sub Test2() Dim vDataIn, vDataOut(), n&, j&, k& Dim lRows&, lCols&, s1$ With Sheets(2) lRows = .Cells(Rows.Count, 1).End(xlUp).Row vDataIn = .Range("A2:C" & lRows) End With 'Sheets("Sheet1") ReDim vDataOut(UBound(vDataIn) * UBound(vDataIn), 8) For n = LBound(vDataIn) To UBound(vDataIn) s1$ = "(IF((A2:A" & lRows & "=""" & vDataIn(n, 1) & """)*(C2:C" _ & lRows & "=""" & vDataIn(n, 3) & """),B2:B" & lRows & "))" For j = LBound(vDataIn) To UBound(vDataIn) k = k + 1 vDataOut(k, 1) = vDataIn(n, 1) vDataOut(k, 2) = vDataIn(n, 3) vDataOut(k, 3) = "Min" vDataOut(k, 4) = Evaluate("=MIN" & s1) vDataOut(k, 5) = "Max" vDataOut(k, 6) = Evaluate("=MAX" & s1) vDataOut(k, 7) = "Avg" vDataOut(k, 8) = Evaluate("=AVERAGE" & s1) Next 'j Next 'n lRows = UBound(vDataOut): lCols = UBound(vDataOut, 2) Sheets("Sheet1").Range("G1").Resize(lRows, lCols) = vDataOut End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to read Excel Array to vb.net Arrays? | Excel Programming | |||
Dynamic Sum Array Formula Input Help | Excel Discussion (Misc queries) | |||
Converting an array formula to VBA | Excel Programming | |||
array formula with a dynamic range. | Excel Worksheet Functions | |||
dynamic arrays in excel | Excel Programming |