+ Reply to Thread
Results 1 to 2 of 2

Help: Activecell within Do loop problem

Hybrid View

  1. #1
    Registered User
    Join Date
    12-12-2005
    Posts
    1

    Help: Activecell within Do loop problem

    Please help
    I am attempting some programming and I am having trouble with the activecell command within a do loop.
    What I am attempting to do is go through a row and have an event occurr on particular cell values. The problem is that when I attempt to the use the activecell.value command to trigger the loop to stop excel does not appear to read the cell value and thus stop the loop. It does not appear to read the cell value property.
    Can you advise me whether I am doing something completely incorrect, or whether there is another way to have the program read a cell value and trigger an output.

    Here is an example of the code I am using

    For a = 1 To n
    Application.Goto reference:="project_inclusion_start"
    c = 0
    Do Until ((ActiveCell.value) ="yes")
    e = a + c
    ActiveCell.Offset(a + c).Activate
    If (ActiveCell.value="yes") Then Exit Do
    c = c + 1
    If c < 5 Then Exit Do
    Loop

    ActiveCell.Offset(0, -1).Activate
    plyearsV(a) = ActiveCell.value
    ActiveCell.Offset(0, -1).Activate
    namesv(a) = ActiveCell.value
    Next a

    The code does the following
    It goes to a reference, and moves down a row untill it finds a cell with the value "yes"
    When this cell is fouund it adds the two values offsetting the cell to a different array.
    Then it goes back to the start and moves down to the cell after this one.
    The problem is that the activecell.value function is always reading as "no", even when the input value is "yes".

    Thanks
    Dave

  2. #2
    Bob Phillips
    Guest

    Re: Activecell within Do loop problem

    Haven't tested it as I don't have any idea of the data, but maybe don't do
    the final activating

    For a = 1 To n
    Application.Goto reference:="project_inclusion_start"
    c = 0
    Do Until ((ActiveCell.Value) = "yes")
    e = a + c
    ActiveCell.Offset(a + c).Activate
    If (ActiveCell.Value = "yes") Then Exit Do
    c = c + 1
    If c < 5 Then Exit Do
    Loop

    plyearsV(a) = ActiveCell.Offset(0, -1).Value
    namesv(a) = ActiveCell.Offset(0, -2).Value
    Next a


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "DavidShepherd" <DavidShepherd.1zx7oa_1134380101.4869@excelforum-nospam.com>
    wrote in message
    news:DavidShepherd.1zx7oa_1134380101.4869@excelforum-nospam.com...
    >
    > Please help
    > I am attempting some programming and I am having trouble with the
    > activecell command within a do loop.
    > What I am attempting to do is go through a row and have an event occurr
    > on particular cell values. The problem is that when I attempt to the use
    > the activecell.value command to trigger the loop to stop excel does not
    > appear to read the cell value and thus stop the loop. It does not
    > appear to read the cell value property.
    > Can you advise me whether I am doing something completely incorrect, or
    > whether there is another way to have the program read a cell value and
    > trigger an output.
    >
    > Here is an example of the code I am using
    >
    > For a = 1 To n
    > Application.Goto reference:="project_inclusion_start"
    > c = 0
    > Do Until ((ActiveCell.value) ="yes")
    > e = a + c
    > ActiveCell.Offset(a + c).Activate
    > If (ActiveCell.value="yes") Then Exit Do
    > c = c + 1
    > If c < 5 Then Exit Do
    > Loop
    >
    > ActiveCell.Offset(0, -1).Activate
    > plyearsV(a) = ActiveCell.value
    > ActiveCell.Offset(0, -1).Activate
    > namesv(a) = ActiveCell.value
    > Next a
    >
    > The code does the following
    > It goes to a reference, and moves down a row untill it finds a cell
    > with the value "yes"
    > When this cell is fouund it adds the two values offsetting the cell to
    > a different array.
    > Then it goes back to the start and moves down to the cell after this
    > one.
    > The problem is that the activecell.value function is always reading as
    > "no", even when the input value is "yes".
    >
    > Thanks
    > Dave
    >
    >
    > --
    > DavidShepherd
    > ------------------------------------------------------------------------
    > DavidShepherd's Profile:

    http://www.excelforum.com/member.php...o&userid=29567
    > View this thread: http://www.excelforum.com/showthread...hreadid=492655
    >




+ 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