I fill the array wit:
for y=0 to ....
....
ReDim Preserve strDBRows3(CONT2)
strDBRows3(CONT2) = strDBRows(3, Y)
CONT2 = CONT2 + 1
....
next y
now how to pass the filled strDBRows3, in this code:
Sub CALCOLO_MEDIE()
Dim RngAddr As String
Dim Rng As Range
Dim Avg As Double
Dim Min As Double
Dim Max As Double
Set Rng = strDBRows3(CONT2<error here
With Application.WorksheetFunction
Avg = .Average(Rng)
Min = .Min(Rng)
Max = .Max(Rng)
End With
End Sub
note:
strDBRows3 is pubblic dimensioned
pass array value in average function...
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: pass array value in average function...
An array is not the same as a range. Fortunately, you don't need to use a range here. Average, Min and Max work fine with arrays. So you can use
Code: Select all
With Application.WorksheetFunction
Avg = .Average(strDBRows3)
Min = .Min(strDBRows3)
Max = .Max(strDBRows3)
End With
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: pass array value in average function...
I l**** YOUHansV wrote:An array is not the same as a range. Fortunately, you don't need to use a range here. Average, Min and Max work fine with arrays. So you can use
Code: Select all
With Application.WorksheetFunction Avg = .Average(strDBRows3) Min = .Min(strDBRows3) Max = .Max(strDBRows3) End With