+ Reply to Thread
Results 1 to 5 of 5

Speed up slow autofit and hide row vba

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    Derbyshire
    MS-Off Ver
    Excel 2000
    Posts
    4

    Speed up slow autofit and hide row vba

    Hi,

    We've recently updated our computers and as such moved from Excel 2000 to Excel 2010. It became immediately obvious that some of the macros which ran almost instantaneously in Excel 2000 have now become sluggish in Excel 2010. One of these macros is used to hide a row in a given range dependant on the value ("True" or "False") given in a helper column as well as resizing and auto fitting the rows in this range. Code below.

    Sub Autofit_HideRows()

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Dim rRow As Range
    With Range("B10:B391").EntireRow
    .Autofit
    For Each rRow In .Rows
    If rRow.RowHeight < 30 Then rRow.RowHeight = 30
    Next rRow
    End With

    Range("A10:A379").Select
    For Each Cell In Selection
    If Cell = False Then
    Range(Cell.Address).EntireRow.Hidden = True
    End If
    Next
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub

    I've tried searching for ways to speed up the process with no luck so here I'm asking for advice.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    09-22-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    36

    Re: Speed up slow autofit and hide row vba

    Try this;
    Please Login or Register  to view this content.
    'Ignoramus et ignorabimus'

  3. #3
    Registered User
    Join Date
    01-08-2013
    Location
    Derbyshire
    MS-Off Ver
    Excel 2000
    Posts
    4

    Re: Speed up slow autofit and hide row vba

    Hi Red Spot,

    Thanks for the code, which looks a lot cleaner and ordered than mine. But is unfortunately slower. I don't understand.

    I know it might not sound much but in Excel 2000 the code ran almost unnoticed as the user clicked the button the sheet reacted without to much of a noticeable pause but now it hangs for about 12 seconds.

    I'm asking to much of Excel 2010.

    Thanks

  4. #4
    Registered User
    Join Date
    09-22-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    36

    Re: Speed up slow autofit and hide row vba

    You can apply an autofilter and use that to remove the lines that have False in Column A, but I doubt it will solve it for you.
    Sounds more like you have a shortage of RAM in your PC.

    At a previous employer they used Vista with 1GB RAM and exstensive use of Access, everything went at a crawl, untill they put an other GB of RAM in our PC's.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Speed up slow autofit and hide row vba

    Does this help?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    In to variable loop, using the last row

    Please Login or Register  to view this content.

+ 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