LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro statement won't execute

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!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Execute Macro dennis[_2_] Excel Worksheet Functions 4 January 17th 09 04:47 PM
the macro don't execute robson soares Excel Programming 5 January 12th 06 06:57 PM
execute a macro Rossy Excel Programming 2 December 15th 05 09:04 AM
Execute Macro Yves Excel Discussion (Misc queries) 3 April 23rd 05 04:26 PM
Excel 2002 Macro to Execute SQL Statement David Weilmuenster[_2_] Excel Programming 0 July 15th 04 01:10 AM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"