Your issue is almost certainly the use of ActiveWorkbook in the UDF. I assume you want to refer to the workbook the function is in, in which case use ThisWorkbook instead. If however the code is in a separate workbook (eg an add-in) then you could refer to the workbook that contains the 'phase' range by using:
For Each CBSheet In phase.parent.parent.Worksheets