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....
Please HELP!
I have been trying to work around this for the past three days......no luck....
Thank you very much!
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!