I have a macro that cycles through each of the named ranges within the workbook to build an inventory or list of names ranges associated with specific worksheets in the workbook. The macro looks to exclude any print areas and any single-cell ranges since I don't need those in the inventory. The following code runs fine on Windows but aborts out of Excel on Mac.
I am unable to pinpoint the exact line in which Excel aborts, but a Mac user thinks it has to do with the RefersToRange statement above. Has anyone else seen this? if so, is there a workaround that will work for Windows and Mac?
Thanks in advance.
Code:
For Each Named_Range In ThisWorkbook.Names
Include_Name = False
Test_Name = ""
Range_Name = ""
' Trap error on Values tab because Results Order has not yet been populated
On Error Resume Next
Test_Name = Named_Range.RefersToRange.Parent.Name
Range_Name = Named_Range.Name
On Error GoTo 0
' Exclude print areas and empty ranges
If InStr(Range_Name, "Print_Area") = 0 And Test_Name <> "" Then
' Exclude single-cell ranges - must be separate if statement to eliminate error if empty range
If WorksheetFunction.CountA(Range(Named_Range)) > 1 Then
Array_Counter = 0
Do
If Included_Sheets(Array_Counter) = Test_Name Then
Include_Name = True
End If
Array_Counter = Array_Counter + 1
Loop Until Include_Name Or Array_Counter = UBound(Included_Sheets)
I am unable to pinpoint the exact line in which Excel aborts, but a Mac user thinks it has to do with the RefersToRange statement above. Has anyone else seen this? if so, is there a workaround that will work for Windows and Mac?
Thanks in advance.