Function InsertArrayFormula .SendKeys for large array formula stop working

stewegg

New Member
Joined
Mar 26, 2012
Messages
2
Hi guys,

I am currently using the debug.print InsertArrayFormula to insert super long array formula (shown below).
I use this on the weekly basis. Everything worked well every single week until this week......
I believe after couple of Windows updates the .sendkeys no longer works properly....

VBA Code:
Function InsertArrayFormula(r As Range, _
              sFrm As String, _
              iRef As XlReferenceStyle, _
              Optional ByVal sFmt As String = "") As Boolean
  ' shg 2009, 2012

  ' Inserts the A1 or R1C1 array formula sFrm into r
  ' The VBE CANNOT have focus when this runs!

  Dim iRefSav   As XlReferenceStyle   ' current ref style
  Dim rSel    As Range        ' current selection

  If r.Worksheet.ProtectContents Then Exit Function
    
  Set rSel = ActiveWindow.RangeSelection
 
  With Application
    iRefSav = .ReferenceStyle
    .ReferenceStyle = iRef
    
    On Error GoTo Oops
    .ScreenUpdating = False

    With r.Areas(1)
      ' Can't put an array formula in cells that are
      ' not either all locked or all unlocked, so ...
      .Locked = .Cells(1).Locked

      ' Cache the number format, set to text, insert formula, restore format
      If Len(sFmt) = 0 Then sFmt = .NumberFormat
      .NumberFormat = "@"
      .Value = sFrm
      .NumberFormat = sFmt

      Application.GoTo .Cells
    End With

    DoEvents
    .SendKeys "{F2}^+{ENTER}"
    DoEvents
    .GoTo rSel
    InsertArrayFormula = True

Outtahere:
    .ReferenceStyle = iRefSav
    .ScreenUpdating = True
    Exit Function
  End With


Oops:
  Resume Outtahere
End Function


Please HELP!
I have been trying to work around this for the past three days......no luck....

Thank you very much!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,551
Messages
6,120,159
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top