I have created a user defined function (UDF) in Excel VBA, which picks up contents from 2 columns and evaluates to a result. The UDF evaluates correctly when no other workbooks are open, but changes to zero when any other workbooks are opened simultaneously. I think the issue is in the first few steps, where I read the input:
Set Sheet = ThisWorkbook.Worksheets(inputSheet)
For i = 0 To numrows
array_multi(i, 0) = Cells(inputRow1 + i, inputCol1)
array_multi(i, 1) = Cells(inputRow2 + i, inputCol2)
Next
Can someone help me resolve the issue here? Let me know if you require more details.
Cells()must be referenced in the sheet where they are supposed to be, or the values will be read in theActivesheet.