RefersToRange error for Mac?

dhregan

New Member
Joined
Mar 30, 2010
Messages
37
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.

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.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top