Function Check Multiple Named Ranges Exist

less than 1 minute read

Function to check if multiple named ranges exist

'==============================================================================
' ## Function: Check multiple named ranges exist
'==============================================================================
Function RangeExists(s As String) As Boolean
    On Error GoTo myExit
    RangeExists = Range(s).Count > 0
myExit:
End Function

' Function example:
Sub CheckRanges()
    Dim vNames As Variant, v As Variant

    vNames = Array("ABC", "DEF", "GHI", "JKL", "MNO")
    For Each v In vNames
        Debug.Print v, RangeExists(CStr(v))
    Next
End Sub