Closed Thread
Results 1 to 3 of 3

Need to compare values in two colums and delete accordingly

  1. #1

    Need to compare values in two colums and delete accordingly

    In a row, if column A and column C have the same value, I need to
    delete that row and then loop through to the end of the spreadsheet.

    Can anyone assist?

    Thank you


  2. #2
    Tom Ogilvy
    Guest

    Re: Need to compare values in two colums and delete accordingly

    lastrow = cells(rows.count,1).end(xlup).row
    for i = lastrow to 1 step -1
    if cells(i,"A").Value = cells(i,"C").Value then
    rows(i).Delete
    end if
    Next


    --
    Regards,
    Tom Ogilvy


    <[email protected]> wrote in message
    news:[email protected]...
    > In a row, if column A and column C have the same value, I need to
    > delete that row and then loop through to the end of the spreadsheet.
    >
    > Can anyone assist?
    >
    > Thank you
    >




  3. #3
    Tim Williams
    Guest

    Re: Need to compare values in two colums and delete accordingly

    Something like this (untested) should work. Adjust loop limits to suit.

    dim i as long
    with thisworkbook.sheets("sheetname")
    for i = 1000 to 1 step -1

    if .cells(i,1).value<>"" and .cells(i,1).value = .cells(i,3).value
    then
    .rows(i).delete
    end if

    next i
    end with


    Tim

    --
    Tim Williams
    Palo Alto, CA


    <[email protected]> wrote in message
    news:[email protected]...
    > In a row, if column A and column C have the same value, I need to
    > delete that row and then loop through to the end of the spreadsheet.
    >
    > Can anyone assist?
    >
    > Thank you
    >




Closed 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