W
w_c_mead
I have a simple statement in a function that attempts to set the value in a
particular cell. Instead, the macro appears to just stop executing when I
try to step into or over the statement with the debugger.
Here's the function in a simplified form:
Function aa_test_set(nsheet As Integer) As Integer
Dim isheet As Integer
isheet = nsheet
Worksheets(3).Cells(10, 2).Value = isheet
aa_test_set = 3
End Function
The offending statement seems to be the one where ...Value = isheet.
The function arguments are just used to allow stepping through the function,
and have no particular significance (I think). When I enter the function
into the calling cell, I provide an integer, such as 10, as the function
argument.
When I step into or over this statement, the debugger just quits doing
anything (apparently the function returned prematurely). The highlighted
statement in the debugger returns to white. The targeted cell value never
gets set. The cell containing the function call displays "#VALUE!". The
workbook has many worksheets, so 5 should not be out of range. (It doesn't
help to refer to the target sheet as a quoted name instead of an index.) The
target cell has format "General".
If I try to run the macro without a breakpoint set, the VB window stops with
the function name highlighted. I can step forward to the statement above,
but the same behavior occurs.
The problem occurs in more than one version of Excel (2002 is the latest
I've tried).
I've found an example statement that's very similar in the VBA help under
the topic "Referring to Cells by Using Index Numbers".
There is an error message in Excel 2002 next to the cell into which I
entered the function saying "Error in value." However, none of the help
suggestions helps me to recognize the problem.
I'm probably missing something obvious (?!?), but I'm stuck.
I'd greatly appreciate your help!
particular cell. Instead, the macro appears to just stop executing when I
try to step into or over the statement with the debugger.
Here's the function in a simplified form:
Function aa_test_set(nsheet As Integer) As Integer
Dim isheet As Integer
isheet = nsheet
Worksheets(3).Cells(10, 2).Value = isheet
aa_test_set = 3
End Function
The offending statement seems to be the one where ...Value = isheet.
The function arguments are just used to allow stepping through the function,
and have no particular significance (I think). When I enter the function
into the calling cell, I provide an integer, such as 10, as the function
argument.
When I step into or over this statement, the debugger just quits doing
anything (apparently the function returned prematurely). The highlighted
statement in the debugger returns to white. The targeted cell value never
gets set. The cell containing the function call displays "#VALUE!". The
workbook has many worksheets, so 5 should not be out of range. (It doesn't
help to refer to the target sheet as a quoted name instead of an index.) The
target cell has format "General".
If I try to run the macro without a breakpoint set, the VB window stops with
the function name highlighted. I can step forward to the statement above,
but the same behavior occurs.
The problem occurs in more than one version of Excel (2002 is the latest
I've tried).
I've found an example statement that's very similar in the VBA help under
the topic "Referring to Cells by Using Index Numbers".
There is an error message in Excel 2002 next to the cell into which I
entered the function saying "Error in value." However, none of the help
suggestions helps me to recognize the problem.
I'm probably missing something obvious (?!?), but I'm stuck.
I'd greatly appreciate your help!