Format Column from UDF

Feb 17, 2015 at 5:09 AM
In the code below, i am attempting to set the formatting of a column from a UDF call. The udf function is marked with 'IsMarcroType=true'. The code below is throwing an exception i am attempting to retrieve a range from the worksheet cells.
using ExcelI = Microsoft.Office.Interop.Excel;

        public static void FormatCol(ExcelReference xlRef, int colIndx, string formatStr)
        {
            ExcelI.Application xlApp = ExcelDnaUtil.Application as ExcelI.Application;
            string sheetNm = (string)XlCall.Excel(XlCall.xlSheetNm, xlRef);
            sheetNm = sheetNm.Substring(sheetNm.IndexOf("]") + 1);
            ExcelI.Worksheet xlActiveSheet = xlApp.Worksheets[sheetNm];
            ExcelI.Range range = xlActiveSheet.Cells[0, colIndx];
            range.EntireColumn.NumberFormat = formatStr;
        }
The exception i see is :
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)   at Microsoft.Office.Interop.Excel.Range.get__Default(Object RowIndex, Object ColumnIndex)
Can anyone help in resolving this...that is how to format either an entire column or range from a UDF (again i believe i am correctly queuing the code that does this to execute in a 'macro' thread).