+ Reply to Thread
Results 1 to 2 of 2

How to fix cell.entirerow.delete?

  1. #1
    guy
    Guest

    How to fix cell.entirerow.delete?

    I am checking cells in a column for a value and when found I do cell.entirerow.delete but my for
    each loop must be messing up because some rows are skipped. How done?

    for each mycell in myrange
    if mycell.value = "delete" then
    mycell.entirerow.delete
    end if
    next

  2. #2
    Robin Hammond
    Guest

    Re: How to fix cell.entirerow.delete?

    Guy,

    you are messing up the range definition with each delete. You need to work
    down from the end of the range. e.g.

    lRows = MyRange.Rows.Count
    For lCounter = lRows to 1 Step -1
    if MyRange(lCounter,1).Value = "delete" Then _
    MyRange(lCounter,1).EntireRow.Delete
    Next lCounter

    Robin Hammond
    www.enhanceddatasystems.com

    "guy" <[email protected]> wrote in message
    news:[email protected]...
    >I am checking cells in a column for a value and when found I do
    >cell.entirerow.delete but my for
    > each loop must be messing up because some rows are skipped. How done?
    >
    > for each mycell in myrange
    > if mycell.value = "delete" then
    > mycell.entirerow.delete
    > end if
    > next




+ 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