remove all array formulas that are programmatically closed

An easy solution to remove all array formulas in column E would be to loop through the column and check the Range.HasArray property in each cell.

Option Explicit

Public Sub RemoveAllArrayFormulasInColumnE()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    
    Dim LastRow As Long
    LastRow = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row
    
    Dim iRow As Long
    For iRow = 1 To LastRow
        If ws.Cells(iRow, "E").HasArray Then
            ws.Cells(iRow, "E").CurrentArray.ClearContents
        End If
    Next iRow
End Sub

To make that even faster you can jump in the loop to the end of current array you delete. This way you have less cells to check.

Option Explicit

Public Sub RemoveAllArrayFormulasInColumnE_Quicker()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    
    Dim LastRow As Long
    LastRow = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row
    
    Dim iRow As Long
    For iRow = 1 To LastRow
        If ws.Cells(iRow, "E").HasArray Then
            Dim JumpRow As Long
            JumpRow = iRow - 1 + ws.Cells(iRow, "E").CurrentArray.Rows.Count
            ws.Cells(iRow, "E").CurrentArray.ClearContents
            iRow = JumpRow
        End If
    Next iRow
End Sub

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top