+ Reply to Thread
Results 1 to 3 of 3

VB Slows to Crawl when Deleting Rows

Hybrid View

  1. #1
    forbesy
    Guest

    VB Slows to Crawl when Deleting Rows

    The macro is pretty basic. If the activecell has a value of 0 then the
    entire row is deleted if not 0 then offset to the next row down and loop.
    The problem seems to be that the spreadsheet has several dozon groupings.
    After about 100 rows into the process the looping slows to one row every few
    seconds and it just keeps getting slower and sloower and sloowweeerrr.

    Any thoughts/suggestions?

    Windows XP SP1
    512 MB memory
    Excel 2002 SP2

    Sub DeleteZeroDataIAN()
    Application.ScreenUpdating = False
    Range("bl10").Activate
    Do Until i = 650

    If ActiveCell.Value <> "" And ActiveCell.Value = 0 Then

    ActiveCell.EntireRow.Delete

    Else
    ActiveCell.Offset(1).Activate


    End If

    i = i + 1

    Loop

    Application.ScreenUpdating = True
    End Sub



  2. #2
    Doug Glancy
    Guest

    Re: VB Slows to Crawl when Deleting Rows

    All those activates will slow things down. Take a look here:

    http://www.rondebruin.nl/delete.htm#AutoFilter

    hth,

    Doug

    "forbesy" <forbesy@discussions.microsoft.com> wrote in message
    news:193E869E-991C-40CF-9042-6B7D0F0C4F47@microsoft.com...
    > The macro is pretty basic. If the activecell has a value of 0 then the
    > entire row is deleted if not 0 then offset to the next row down and loop.
    > The problem seems to be that the spreadsheet has several dozon groupings.
    > After about 100 rows into the process the looping slows to one row every

    few
    > seconds and it just keeps getting slower and sloower and sloowweeerrr.
    >
    > Any thoughts/suggestions?
    >
    > Windows XP SP1
    > 512 MB memory
    > Excel 2002 SP2
    >
    > Sub DeleteZeroDataIAN()
    > Application.ScreenUpdating = False
    > Range("bl10").Activate
    > Do Until i = 650
    >
    > If ActiveCell.Value <> "" And ActiveCell.Value = 0 Then
    >
    > ActiveCell.EntireRow.Delete
    >
    > Else
    > ActiveCell.Offset(1).Activate
    >
    >
    > End If
    >
    > i = i + 1
    >
    > Loop
    >
    > Application.ScreenUpdating = True
    > End Sub
    >
    >




  3. #3
    forbesy
    Guest

    Re: VB Slows to Crawl when Deleting Rows

    Thanks Doug, that worked perfectly!

    "Doug Glancy" wrote:

    > All those activates will slow things down. Take a look here:
    >
    > http://www.rondebruin.nl/delete.htm#AutoFilter
    >
    > hth,
    >
    > Doug
    >
    > "forbesy" <forbesy@discussions.microsoft.com> wrote in message
    > news:193E869E-991C-40CF-9042-6B7D0F0C4F47@microsoft.com...
    > > The macro is pretty basic. If the activecell has a value of 0 then the
    > > entire row is deleted if not 0 then offset to the next row down and loop.
    > > The problem seems to be that the spreadsheet has several dozon groupings.
    > > After about 100 rows into the process the looping slows to one row every

    > few
    > > seconds and it just keeps getting slower and sloower and sloowweeerrr.
    > >
    > > Any thoughts/suggestions?
    > >
    > > Windows XP SP1
    > > 512 MB memory
    > > Excel 2002 SP2
    > >
    > > Sub DeleteZeroDataIAN()
    > > Application.ScreenUpdating = False
    > > Range("bl10").Activate
    > > Do Until i = 650
    > >
    > > If ActiveCell.Value <> "" And ActiveCell.Value = 0 Then
    > >
    > > ActiveCell.EntireRow.Delete
    > >
    > > Else
    > > ActiveCell.Offset(1).Activate
    > >
    > >
    > > End If
    > >
    > > i = i + 1
    > >
    > > Loop
    > >
    > > Application.ScreenUpdating = True
    > > End Sub
    > >
    > >

    >
    >
    >


+ 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