I am put together a UDF (C_Formula) that looks up and puts cell values of a formula into a string.
Everything was working as expected for cell references on the same sheet. I'm running into a problem when it references a cell on another worksheet.
entered formula = C_Formula(A3)
should lookup = C_Formula("=Sheet2!A1")
should return = 50
strCell = strSheet + strCell;
ExcelReference refCell = (ExcelReference)Excel(xlfIndirect, strCell, true);
object objCell = refCell.GetValue();
strCell = ToolsArgs.GetStr(objCell);
When the code gets to the line:
ExcelReference refCell = (ExcelReference)Excel(xlfIndirect, strCell, true); (Line 173 in attached PDF),
Excel freezes for a minute and then crashes with no exception being thrown. The Visual Studio output log just lists:
The program ' EXCEL.EXE' has exited with code 3762504530 (0xe0434352).
Any chance someone can point out what I'm doing wrong? Thanks!