+ Reply to Thread
Results 1 to 3 of 3

Testing Spreadsheet Cells while in a Macro

Hybrid View

  1. #1
    Amaross
    Guest

    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.



  2. #2
    Otto Moehrbach
    Guest

    Re: 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" <Amaross@discussions.microsoft.com> wrote in message
    news:78EF261D-CC9D-4A62-A4CC-D4949F6184A2@microsoft.com...
    >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.
    >
    >




  3. #3
    Amaross
    Guest

    Re: 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" <Amaross@discussions.microsoft.com> wrote in message
    > news:78EF261D-CC9D-4A62-A4CC-D4949F6184A2@microsoft.com...
    > >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.
    > >
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1