La macro completa va así:
Sub eliminarceros_quarliles()
ult = Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For r = 24 To 35
rango = "Segmento" + Trim(Str(r - 23))
Sheets("Panel de control2").Select
ReDim ArrayCriterio(20) As String
Inicio = Range("B" + Trim(Str(r))).Text
Fin = Range("C" + Trim(Str(r))).Text
If Inicio <> "" And Fin <> "" Then
'Construimos la cadena de los años a filtrar
For i = Inicio To Fin
ArrayCriterio(i - Inicio) = i
Next
Sheets(rango).Select
Range("BC:CX").Select
For col = 5 To 47
For fil = 1 To 5001
ActiveSheet.Cells(fil, col).Select
If ActiveCell.Text = "0" Then
ActiveCell.ClearContents
End If
Next fil
Next col
ActiveSheet.Cells(1, 1).Select
Dim contador As Double
Dim k As Double
Dim m As Double
x = 1.5
y = 1.5
Range("AX1").Select
ActiveCell.FormulaR1C1 = "CUARTIL1"
Range("AY1").Select
ActiveCell.FormulaR1C1 = _
"=QUARTILE(R2C[-46]:R1048576C[-46],1)-" & x & "*((QUARTILE(R2C[-46]:R1048576C[-46],3)-(QUARTILE(R2C[-46]:R1048576C[-46],1))))"
Range("AY1").Select
Selection.Copy
Range("AY1:CO1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("AX2").Select
ActiveCell.FormulaR1C1 = "CARTIL2"
Range("AY2").Select
ActiveCell.FormulaR1C1 = _
"=QUARTILE(R2C[-46]:R1048576C[-46],3)+" & y & "*((QUARTILE(R2C[-46]:R1048576C[-46],3)-(QUARTILE(R2C[-46]:R1048576C[-46],1))))"
Range("AY2").Select
Selection.Copy
Range("AY2:CO2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("CU2").Select
Range("AY3").Select
ActiveCell.FormulaR1C1 = "=R[-2]C[-46]"
Range("AY3").Select
Selection.Copy
Range("AY3:CO3").Select
ActiveSheet.Paste
Range("AY4").Select
ActiveCell.Value = "=IF(R[-2]C[-46]="""","""",IF(AND(R[-2]C[-46]>=R1C,R[-2]C[-46]<=R2C),R[-2]C[-46],""""))"
''''''
Range("AY4").Select
Selection.AutoFill Destination:=Range("AY4:CO4"), Type:=xlFillDefault
Range("AY4:CO4").Select
Selection.AutoFill Destination:=Range("AY4:CO406"), Type:=xlFillDefault
Range("AY4:CO406").Select
Sheets("Panel de control2").Select
Range("D1").Select
End If
Next r
Application.ScreenUpdating = True
End Sub
DAN me podrías mostrar que es QUARTILE y porque la fórmula R1C1 ahí se ve así R2C[-46] y no así R[2]C[-46] me salio esa duda - jairo retorno
Hola: Puedes revisarlo aquí: https://es.wikipedia.org/wiki/Cuartil . Los corchetes son para establecer si la referencia es relativa o absoluta. saludos - Dante Amor