+ Reply to Thread
Results 1 to 7 of 7

Slow Case Select code

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Slow Case Select code

    Hi Folks

    I have really slowly executing code for a Select Case. Its referencing a named range hower when I referenced a set block (the same size as the named range) it was just as slow.

    All its doing is conditional formating a cell on the value of a cell 4 columns to the right.

    Please Login or Register  to view this content.
    any suggestions?
    Cheers
    Kranky

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,011

    Re: Slow Case Select code

    Maybe try switching off screen updating and calculation before the code and back on again afterwards.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Slow Case Select code

    Hi, Kranky,

    is it really necessary to run the code or may the coloring be done when the checked cell changes (either by entry or by formula)?

    CurrentSheet isnīt set in the code, and as you have referenced the sheet and the range in the area to loop you would not need to activate the sheet.

    Additional to Trevorīs suggestion: if you make heavy use of formulas in that workbook you could set calculation to manual and back to automatic at the end. You may even put Excel in the Tray (minimize) for the length of the macro.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    09-24-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Slow Case Select code

    Thanks gents

    Tried the switching screen updating and calcs off and on afterwards. No gains. We're talking about a dozen seconds.

    Holger, yes the code needs to run as it then sets the colour for the appropriate ranges pie chart.

    So the run of the code is:
    Create pie chart from range that all have the same value. Colour the range cells (as above) then the pie segments are coloured to the source cell. The last part doesn't work if the range cells are conditional formated.

    I use similar code in another book however it references specific cells and in a set range. The range I'm trying to work on currently will grow every day, the previous range never and the code was instantaneous..

    Thanks again

    Kranky

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,011

    Re: Slow Case Select code

    You probably need to share (a sample of) the workbook ... and maybe the one that works.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Slow Case Select code

    Please Login or Register  to view this content.



  7. #7
    Registered User
    Join Date
    09-24-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Slow Case Select code

    Thanks snb

    Code runs till line 21 then gets application or object defined error
    Please Login or Register  to view this content.
    So far
    Please Login or Register  to view this content.
    Cheers
    Kranky

+ 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