/ / Impossível obter a propriedade formularArray da classe range - excel-vba, vba, excel

Não é possível obter a propriedade formularArray da classe de intervalo - excel-vba, vba, excel

Abaixo está o meu código, eu recebo este erro:

não é possível definir a propriedade formulararray da classe de intervalo

Sub Auto_TTAnalysis_RANREPORT()
"
" Auto_TTAnalysis_RANREPORT Macro
"

"
Columns("B:B").Select
Selection.Copy
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Columns("K:K").Select
Application.CutCopyMode = False
Selection.Copy
Columns("N:N").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False
Selection.Copy
Columns("O:O").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False
Selection.Copy
Columns("P:P").Select
Selection.Insert Shift:=xlToRight
Range("M1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "BTS"
Range("N1").Select
ActiveCell.FormulaR1C1 = "Category"
Range("O1").Select
ActiveCell.FormulaR1C1 = "Outage in ins"
Range("P1").Select
ActiveCell.FormulaR1C1 = "15 mins"
Range("N2").Select
Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No Site Outage"",IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell Outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst Cell"",""Site Outage"")))"
Range("N2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O2").Select
Application.CutCopyMode = False
Selection.FormulaArray = "=(100-AVERAGEIFS(C[-3],C[-13],RC[-2]))*24*60/100"
Range("O2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P2").Select
Application.CutCopyMode = False
Selection.FormulaArray = _
"=IF(RC[-1]>15,""More than 15 mins"",""Within 15  mins"")"
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$1:$P$8275").AutoFilter Field:=12, Criteria1:="0.00"
Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Range("K1").Select
Selection.AutoFilter
Range("A1").Select
Sheets("HUAWEI").Select
Selection.CurrentRegion.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Font
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlGeneral
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1").Select
Selection.AutoFilter
Columns("I:J").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Selection.Copy
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Columns("N:N").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Columns("O:O").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Columns("P:P").Select
Selection.Insert Shift:=xlToRight
Range("N1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Category"
Range("O1").Select
ActiveCell.FormulaR1C1 = "Outages in min"
Range("P1").Select
ActiveCell.FormulaR1C1 = "15 mins"
Range("N2").Select
Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No site outage"",IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst cell"",""Site outage"")))"
Range("N2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O2").Select
Application.CutCopyMode = False
Selection.FormulaArray = "=(100-AVERAGEIFS(C[-3],C[-13],RC[-2]))*24*60/100"
Range("O2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P2").Select
Application.CutCopyMode = False
Selection.FormulaArray = _
"=IF(RC[-1]>15,""More than 15 mins"",""Within 15 mins"")"
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Sheets("ZTE").Select
Range("B1").Select
Selection.Copy
Columns("E:E").Select
Columns("B:B").Select
Application.CutCopyMode = False
Selection.Copy
Columns("E:E").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False
Selection.Copy
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Range("K1").Select
Application.CutCopyMode = False
Selection.Copy
Columns("K:K").Select
Application.CutCopyMode = False
Selection.Copy
Columns("N:N").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False
Selection.Copy
Columns("O:O").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False
Selection.Copy
Columns("P:P").Select
Selection.Insert Shift:=xlToRight
Range("N1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Category"
Range("O1").Select
ActiveCell.FormulaR1C1 = "OUTAGES IN MINS"
Range("P1").Select
ActiveCell.FormulaR1C1 = "15MINS"
Range("N2").Select
Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No site outage"",IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst cell"",""Site Outage"")))"
Range("N2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O2").Select
Application.CutCopyMode = False
Selection.FormulaArray = "=(100-AVERAGEIFS(C[-3],C[-13],RC[-2]))*24*60/100"
Range("O2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P2").Select
Application.CutCopyMode = False
Selection.FormulaArray = _
"=IF(RC[-1]>15,""More than 15 mins,""""Within15mins"")"
Range("P2").Select
Selection.FormulaArray = _
"=IF(RC[-1]>15,""More than 15 mins"",""Within 15 mins"")"
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("M1").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$1:$P$1586").AutoFilter Field:=12, Criteria1:="0.00"
Range("A168").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Range("K1581").Select
Selection.AutoFilter
Range("A1").Select
Sheets("HUAWEI").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$P$22388").AutoFilter Field:=12, Criteria1:="0"
Range("A485").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Range("K1").Select
Selection.AutoFilter
Range("A1").Select
Sheets("ERICSON").Select
End Sub

Respostas:

1 para resposta № 1

Acho que encontrei seu problema, embora possa estar errado, já que de maneira nenhuma vou depurá-lo.
Está linha

Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No Site Outage"",IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell Outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst Cell"",""Site Outage"")))"

provavelmente lançará um erro porque o número de caracteres é superior a 255.
Pergunta StackOverflow Relacionada
Consulte o Artigo de Suporte da Microsoft
Uma solução alternativa que pode funcionar para você é algo assim:

Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100)," & _
"""No Site Outage""," & _
"IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100)," & _
"""No Cell Outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5," & _
"""Worst Cell""," & _
"""Site Outage"")))"

Ele calcula a fórmula de matriz composta de várias strings, cada uma delas com menos de 255 caracteres.


1 para resposta № 2

(Estou expandindo meus comentários sobre a resposta do AntiDrondert para uma resposta completa.)

o .FormulaArray propriedade aceita apenas até 255 caracteres. Você pode contornar isso com o .Replace método, mas que também aceita apenas 255 caracteres por argumento. (Você pode repeti-lo para fazer a fórmula no array o tempo que quiser)

Vou atualizar o seu primeiro Fórmula de Array como um exemplo, para que você possa fazer alterações correspondentes no resto.

Range("N2").Select
Selection.FormulaArray = _
"=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No Site Outage"",IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell Outage"",IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst Cell"",""Site Outage"")))"
Range("N2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Agora, sua fórmula está apenas um pouco acima (ainda abaixo de 300 caracteres), então, em teoria, só necessidade 1 substituir - mas vou usar 2 para que cada um dos seus IF blocos está em uma linha separada.

With Range("N2")
"Each stage in the replace has to be a valid formula.  MAX(1) is short, and unusual, so easy to find/replace
.FormulaArray = "=IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))=100,RC[-2]=100),""No Site Outage"",MAX(1))"
.Replace "MAX(1)", "IF(AND(MIN(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))<100,RC[-2]=100),""No Cell Outage"",Max(1))"
.Replace "MAX(1)", "IF(MAX(IF(RC[-1]=R2C2:R14829C2,R2C12:R14829C12))-RC[-2]>5,""Worst Cell"",""Site Outage"")"
End With
With Range(Range("N2"), Range("N2").End(xlDown))
.FillDown
.Calculate
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With