![]() |
Testing Spreadsheet Cells while in a Macro
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: "argument is not optional". 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. |
Testing Spreadsheet Cells while in a Macro
Not sure if this is what you want, but the code is:
If Range("CellName").Value = "True" Then 'Task if True Else 'Task if False End If Please post back if I missed what you want/need. HTH Otto "Amaross" wrote in message ... 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: "argument is not optional". 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. |
Testing Spreadsheet Cells while in a Macro
This is exactly what I need. You made my day. Thank you ever so much!
"Otto Moehrbach" wrote: Not sure if this is what you want, but the code is: If Range("CellName").Value = "True" Then 'Task if True Else 'Task if False End If Please post back if I missed what you want/need. HTH Otto "Amaross" wrote in message ... 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: "argument is not optional". 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. |
All times are GMT +1. The time now is 02:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com