+ Reply to Thread
Results 1 to 8 of 8

Flickering Cells when I run this code

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    142

    Flickering Cells when I run this code

    I have included the following code. When I run the following code it flickers the selected cells for about 5 seconds and complete the job. I want to know why do the cells flicker for about 5 seconds? The code does what it is suppose to do, just don't like the flickering. What if anything can I do to stop the flickering?



    Sub Contents()
    'This selects the cells to color Green
    Range("C8").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 52377
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    ' This selects the cells to turn Gray
    Range("C9:C15,B11:B13").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = -0.249977111117893
    .PatternTintAndShade = 0
    End With
    ' This selects the cells to clear formulas in
    Worksheets("Scrap Calculator").Range("B9,B10,B14,B15").ClearContents
    End Sub

    Thanks so much

  2. #2
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: Flickering Cells when I run this code

    Add Application.ScreenUpdating = False to the start of the code and Application.ScreenUpdating = True to the end of the code.
    If I've been of help, please hit the star

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

    Re: Flickering Cells when I run this code

    Hi, madhatter40,

    please use the code tags to dipslay the coding.

    Maybe itīs due to calculation? You could try and set the ScreenUpdating of for the macro:
    Please Login or Register  to view this content.
    Code ran in nearly no time - no formulas included in workbook for testing here.

    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
    Forum Contributor
    Join Date
    12-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Flickering Cells when I run this code

    So I updated the code and it does run in about 3 seconds. It still flickers for the 3 seconds. Is it suppose to do that? I was hoping for it to just run with no flickering.

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

    Re: Flickering Cells when I run this code

    Hi, madhatter40,

    which code did you use: the one you supplied or the modified? If itīs yours I assume that there are events which may get fired due to change of selections. As long as you canīt provide a sample workbook I think anybody will have a hard time guessing at what may be the reason for the flickering (I already have used two of my possible three guesses here ).

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    12-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Flickering Cells when I run this code

    I will include all the code that goes with this worksheet.
    The following is what fires when a user selects from a dynamic drop down list:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Range("G2")

    Please Login or Register  to view this content.
    This is the code I modified:

    Please Login or Register  to view this content.
    screen shot.jpg

    I hope this helps. The upper right corner is where the user selects from the drop down menu. (Where is says "Machine PL048")
    Last edited by madhatter40; 12-15-2012 at 09:15 AM. Reason: Sorry I forgot

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Flickering Cells when I run this code

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Contributor
    Join Date
    12-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Flickering Cells when I run this code

    I hvae figured it out. I switched the "Application.ScreenUpdating = False" to the following:

    Application.EnableEvents = True

    OLD Code

    Please Login or Register  to view this content.
    New Code:

    Please Login or Register  to view this content.
    Thanks everyone for the help

+ 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