Results 1 to 6 of 6

Thread: [RESOLVED] Loop Tuning EXCEL

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Resolved [RESOLVED] Loop Tuning EXCEL

    Hi,

    What I want to do is to hide all row that are NOT bold or empty.
    My range starts at row 12 and I don't know at witch row it finishes. I know that it finishes with the text GRAND TOTAL in column A and there is approx. 600 rows. I want this job to be performed when the button is clicked

    So here is what I've done
    VB Code:
    1. Private Sub CommandButton1_Click()
    2.     Application.ScreenUpdating = False
    3.     ActiveSheet.Range("A12").Activate
    4.     Do While (ActiveCell.Value <> "GRAND TOTAL")
    5.         If (ActiveCell.Font.Bold = False Or ActiveCell.Value = "") Then
    6.             ActiveCell.EntireRow.Hidden = True
    7.         End If
    8.         ActiveCell.Offset(1, 0).Activate
    9.     Loop
    10.     Application.ScreenUpdating = True
    11. End Sub

    This loop does all I want, but it takes 45 to 60 sec to accomplish. That is way too long.

    Any idea?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Loop Tuning EXCEL

    Bill
    Try turning calculation off before running the loop, then turn it back on.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Loop Tuning EXCEL

    humm, don't seem to speed it up

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Loop Tuning EXCEL

    Humm, I just ran this on a sheet with 23752 rows and 21 columns and it ran in under 1 second. There must be something else going on with your sheet.
    (This is a stab in the dark) - Do you have any conditional formatting on the sheet?

    Or do you have a worksheet_change or _sectionchange event? If so then disable events when looping.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Loop Tuning EXCEL

    No, but your stab in the dark gived me an hint.

    I've tried the magic tricks of rebooting and it runned under 3 seconds

    Thanks again for your help!!!

    Enjoy windows and magic reboot...

  6. #6
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: [RESOLVED] Loop Tuning EXCEL

    it really only worked because I posted here....

    (oh the joys of MS...)
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width