Hello,
The code below was written to update formulas in F5:N and array formulas in H5:AA, and replace the formulas in F6:A6 and below with the output as values. I am using VBA code to avoid a slow workbook, forcing the formulas to run only after I have updated other data in the workbook.
The code updates the formulas correctly, however the array formulas in rows 6 and below return #N/A. I have searched online and tried adding Array to Formula (FormulaArray) however this returns an error message. I have checked possible reasons for this error and for example, the array formulas are less than the maximum 255 characters. Is it possible to amend the code below to successfully run the array formulas?
The code below was written to update formulas in F5:N and array formulas in H5:AA, and replace the formulas in F6:A6 and below with the output as values. I am using VBA code to avoid a slow workbook, forcing the formulas to run only after I have updated other data in the workbook.
The code updates the formulas correctly, however the array formulas in rows 6 and below return #N/A. I have searched online and tried adding Array to Formula (FormulaArray) however this returns an error message. I have checked possible reasons for this error and for example, the array formulas are less than the maximum 255 characters. Is it possible to amend the code below to successfully run the array formulas?
Code:
Option Explicit
Sub RefreshData()
'Declare variables
Dim desWS As Worksheet, i As Long, LastRow As Long
'Set the sheet
Set desWS = Sheets("View")
With desWS
LastRow = .Range("D" & .Rows.Count).End(xlUp).Row
.Range("F6:AA" & .Rows.Count).ClearContents
For i = 6 To 27
Application.StatusBar = "Updating column " & i & " of 27"
DoEvents
.Range(.Cells(5, i), .Cells(LastRow, i)).Formula = .Cells(5, i).Formula
.Range(.Cells(6, i), .Cells(LastRow, i)).Value = .Range(.Cells(6, i), .Cells(LastRow, i)).Value
Next i
End With
End Sub