JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,531
- Office Version
- 365
- Platform
- Windows
I am working on a UDF that may be more complicated than I can handle. (sigh)
The UDF is called just once from a single cell in the only sheet in the only open workbook. I have break point (F9) set at the top of this section of code:
RngColBeg & RngColEnd are global variables (type Long) calculated by a subroutine.
pRtgsBest is a range passed to the UDF from Excel.
As I step through the code, after executing the two statements inside the loop, the watch window shows that the value of RBestI is "Empty". But the cell that it is supposed to be getting its value from, (E10), contains "900".
I get these results from the Immediate window:
How can RBestI be empty when it was just set to the value in E10 (pRtgsBest(1, iCol)) which is 900 according to the Immediate window?
So, then I press F5 to resume execution. I am immediately brought back to the same break point, but this time, RBestI contains 900.
Can anyone suggest why this UDF is getting executed twice. I've checked and it is not calling itself, as far as I can tell. And why is the value in RBestI wrong the first time and right the second?
I'd appreciate any suggestions for things to try.
I'd post the code somewhere, but it is hundreds of lines.
Thanks
The UDF is called just once from a single cell in the only sheet in the only open workbook. I have break point (F9) set at the top of this section of code:
Code:
. . .
Dim iCol As Long
Dim RBestI As Variant
Dim RBestIAddr As String
. . .
For iCol = RngColBeg To RngColEnd
. . .
RBestI = pRtgsBest(1, iCol)
RBestIAddr = pRtgsBest(1, iCol).Address
. . .
Next i
. . .
RngColBeg & RngColEnd are global variables (type Long) calculated by a subroutine.
pRtgsBest is a range passed to the UDF from Excel.
As I step through the code, after executing the two statements inside the loop, the watch window shows that the value of RBestI is "Empty". But the cell that it is supposed to be getting its value from, (E10), contains "900".
I get these results from the Immediate window:
Code:
?rbesti
?pRtgsBest(1, iCol)
900
?rbestiaddr
$E$10
How can RBestI be empty when it was just set to the value in E10 (pRtgsBest(1, iCol)) which is 900 according to the Immediate window?
So, then I press F5 to resume execution. I am immediately brought back to the same break point, but this time, RBestI contains 900.
Can anyone suggest why this UDF is getting executed twice. I've checked and it is not calling itself, as far as I can tell. And why is the value in RBestI wrong the first time and right the second?
I'd appreciate any suggestions for things to try.
I'd post the code somewhere, but it is hundreds of lines.
Thanks