He visto el número filas que tengo en el Excel este mes y son 65536, lo he cambiado en la expresión:
Sub Percentiles(P As Double)
Dim H1 As Worksheet
Dim H2 As Worksheet
Dim UF As Long
Dim FilaPrimerDato As Long
Dim FilaUltimoDato As Long
Dim ADatos(65536) As Variant
Dim i As Long
Dim j As Long
Dim k As Long
Set H1 = Worksheets("Sheet0")
Set H2 = Worksheets("Resumen")
H2.Rows("2:65536").Delete
With H1
UF = .Cells(65536, 1).End(xlUp).Row
With .Sort.SortFields
.Clear
.Add2 Key:=Range("E2:E" & UF), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add2 Key:=Range("N2:N" & UF), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
With .Sort
.SetRange Range("A1:O" & UF)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
FilaPrimerDato = 2
FilaUltimoDato = UF
k = 0
j = 2
For i = 2 To UF
If .Cells(i + 1, 1) <> .Cells(i, 1) Then
FilaUltimoDato = i + 1
ADatos(k) = .Cells(i, 2)
k = k + 1
H2.Cells(j, 1) = .Cells(FilaPrimerDato, 1)
H2.Cells(j, 2) = WorksheetFunction.Percentile(ADatos, P)
j = j + 1
k = 0
FilaPrimerDato = i + 1
FilaUltimoDato = UF
Else
ADatos(k) = .Cells(i, 2)
k = k + 1
End If
Next
End With
End Sub
Pues ahora me sale un error 438 y me subraya en amarillo:
.Add2 Key:=Range("E2:E" & UF), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
?????
¿Qué pasa ahora? ¿Qué tormento? Gracias por tu ayuda