Hi,
I'm trying to find the column number of a named range (which has been defined previously in my code).
Function findReportNamedRange(reportColCount As Integer) As Integer '6
Dim reportSheet As Worksheet
Dim reportCol As Integer
Dim namedRange As Name
Set reportSheet = Sheets("Report")
For reportCol = reportColCount - 1 To 1 Step -1
Debug.Print reportCol '5
For Each namedRange In ThisWorkbook.Names
Debug.Print namedRange 'prints _xlfn.IFERROR
If Not Intersect(reportSheet.Cells(3, reportCol), namedRange.RefersToRange) Is Nothing Then
findReportNamedRange = reportCol
Debug.Print findReportNamedRange 'should be 1 but doesn't print
Exit For
Exit For
End If
Next
Next reportCol
End Function
Am I missing something obvious here ?
Thanks,
amphi
Bookmarks