Because of the length limitations of Range.FormulaArray, when I need to enter a large array formula in a cell, I enter it as a normal formula and then apply Cntrl+Shift+Enter with SendKeys. For example:
This works fine if I am running it from the worksheet using the Ribbon Menu. However, if I try to run it from the VBA window, it fails. It fails because its the VBE that gets the keystrokes, not Excel.Sub ArFormula() ActiveCell.Formula = "=MAX(IF(A2>B1:B12,B1:B12))" With Application .SendKeys "{F2}" ' get into edit mode .SendKeys "^+~" ' use CNTRL + Shift + Enter End With End Sub
In Excel F2 gets into the Edit mode for a cell, in the VBE, F2 does something else.
Is there any way to modify the code to insure that Excel gets the keystrokes and not the VBE ??