I have created a macro with a loop which periodically has to check a
spreadsheet cell (Boolean value) in order to branch to different
sub-routines. Since VBA makes a distinction between 'parameter' (structure)
and 'argument' (value), the parameter definition in the sub-declaration line
does not allow for its value to be tested, eliciting the error: quot;argument is
not optionalquot;. How then does one test for a cell's value while in a macro?
The cell in question toggles between 0 and 1 depending on data coming in via
DDE. It determines what action should take place in the macro.
I know that the value of an argument can be passed manually to a macro, as in,
-Call (macro-name) (argument),
however, this is not practical in this case because of the large amount of
data involved. What then is VBA's equivalent for the 'procedural' line:
-If (cell/name) = True Then...../Else...../Endif?
Any suggestions will be appreciated.
Not sure if this is what you want, but the code is:
If Range(quot;CellNamequot;).Value = quot;Truequot; Then
'Task if True
Else
'Task if False
End If
Please post back if I missed what you want/need. HTH Otto
quot;Amarossquot; gt; wrote in message
...
gt;I have created a macro with a loop which periodically has to check a
gt; spreadsheet cell (Boolean value) in order to branch to different
gt; sub-routines. Since VBA makes a distinction between 'parameter'
gt; (structure)
gt; and 'argument' (value), the parameter definition in the sub-declaration
gt; line
gt; does not allow for its value to be tested, eliciting the error: quot;argument
gt; is
gt; not optionalquot;. How then does one test for a cell's value while in a
gt; macro?
gt; The cell in question toggles between 0 and 1 depending on data coming in
gt; via
gt; DDE. It determines what action should take place in the macro.
gt;
gt; I know that the value of an argument can be passed manually to a macro, as
gt; in,
gt;
gt; -Call (macro-name) (argument),
gt;
gt; however, this is not practical in this case because of the large amount of
gt; data involved. What then is VBA's equivalent for the 'procedural' line:
gt;
gt; -If (cell/name) = True Then...../Else...../Endif?
gt;
gt; Any suggestions will be appreciated.
gt;
gt;
This is exactly what I need. You made my day. Thank you ever so much!
quot;Otto Moehrbachquot; wrote:
gt; Not sure if this is what you want, but the code is:
gt; If Range(quot;CellNamequot;).Value = quot;Truequot; Then
gt; 'Task if True
gt; Else
gt; 'Task if False
gt; End If
gt; Please post back if I missed what you want/need. HTH Otto
gt; quot;Amarossquot; gt; wrote in message
gt; ...
gt; gt;I have created a macro with a loop which periodically has to check a
gt; gt; spreadsheet cell (Boolean value) in order to branch to different
gt; gt; sub-routines. Since VBA makes a distinction between 'parameter'
gt; gt; (structure)
gt; gt; and 'argument' (value), the parameter definition in the sub-declaration
gt; gt; line
gt; gt; does not allow for its value to be tested, eliciting the error: quot;argument
gt; gt; is
gt; gt; not optionalquot;. How then does one test for a cell's value while in a
gt; gt; macro?
gt; gt; The cell in question toggles between 0 and 1 depending on data coming in
gt; gt; via
gt; gt; DDE. It determines what action should take place in the macro.
gt; gt;
gt; gt; I know that the value of an argument can be passed manually to a macro, as
gt; gt; in,
gt; gt;
gt; gt; -Call (macro-name) (argument),
gt; gt;
gt; gt; however, this is not practical in this case because of the large amount of
gt; gt; data involved. What then is VBA's equivalent for the 'procedural' line:
gt; gt;
gt; gt; -If (cell/name) = True Then...../Else...../Endif?
gt; gt;
gt; gt; Any suggestions will be appreciated.
gt; gt;
gt; gt;
gt;
gt;
gt;
- Nov 03 Mon 2008 20:47
Testing Spreadsheet Cells while in a Macro
close
全站熱搜
留言列表
發表留言