+ Reply to Thread
Results 1 to 4 of 4

loop through rows evaluating 2 cells

  1. #1
    Registered User
    Join Date
    07-27-2005
    Posts
    24

    loop through rows evaluating 2 cells

    I am building a utility that will allow the user to iterate down a range of rows ("A1:K5000"). The script needs to evaluate the following on the active row: If the active cell in column a <> "" and the active cell in column k = "" then the active cell in column k = k4.value.

    Thanks in advance for your assistance!
    Last edited by mthomas; 07-27-2005 at 11:47 AM.

  2. #2
    Tom Ogilvy
    Guest

    Re: loop through rows evaluating 2 cells

    Sub ABCD()
    Dim i as Long, lastrow as Long
    lastrow = cells(rows.count,1).End(xlup).row
    for i = 5 to Lastrow
    if cells(i,1).Value <> "" and cells(i,"K").Value = "" then
    cells(i,"K").value = cells(4,"K").value
    end if
    Next i
    End sub

    --
    Regards,
    Tom Ogilvy
    "mthomas" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I am building a utility that will allow the user to iterate down an
    > undermined amount of rows. The script needs to evaluate the following
    > on the active row: If the active cell in column a <> "" and the active
    > cell in column k = "" then the active cell in column k = k4.value.
    >
    > Thanks in advance for your assistance!
    >
    >
    > --
    > mthomas
    > ------------------------------------------------------------------------
    > mthomas's Profile:

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




  3. #3
    Registered User
    Join Date
    07-27-2005
    Posts
    24
    Tom,

    Thanks for the reply and it works! But could you please explain what this line is doing....

    lastrow = cells(rows.count,1).End(xlup).row

    Thanks again for you help on this and have a great day!

  4. #4
    Tom Ogilvy
    Guest

    Re: loop through rows evaluating 2 cells

    If you went to the bottom of the worksheet (or any cell past you data ) and
    selected a cell, then hit the END key , then the Up Arrow, the selection
    would move to the last cell in that column containing data or a formula.
    That is what the code does - finds the last cell in the column containing
    data or a formula and returning the row number of that cell.

    --
    Regards,
    Tom Ogilvy

    "mthomas" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Tom,
    >
    > Thanks for the reply and it works! But could you please explain what
    > this line is doing....
    >
    > lastrow = cells(rows.count,1).End(xlup).row
    >
    > Thanks again for you help on this and have a great day!
    >
    >
    > --
    > mthomas
    > ------------------------------------------------------------------------
    > mthomas's Profile:

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




+ 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