阵列中的模式未按预期填充

时间:2019-03-06 17:03:41

标签: arrays excel vba

下面的公式应计算所有符合条件的值的模式。

唯一的问题是,而不是数组公式变为“ M2 = etc”,“ M3 = etc”,“ M4 = etc”,所有值均为“ M2”,这与数组应“填充”无关。 “

Image example 1

Image example 2

Sub ModeColumn()

Dim wb As Workbook, ws As Worksheet, LastRow As Long

Set wb = ThisWorkbook
Set ws = Worksheets("Data")

    ws.Cells(1, 15) = "MODE"
    LastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row                  'Finds the bottom populated row

    With ws.Range(ws.Cells(2, 15), ws.Cells(LastRow, 15))
           .FormulaArray = "=IFERROR(MODE(IF(RC[-2]=AllSites,R2C12:R" & LastRow & "C12)),""N/A"")"
    End With


End Sub

请注意,我是通过从可怕的SelectionActive等录制的宏符号转换而得到的

0 个答案:

没有答案