Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Turning off the gui update during vba run

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there a way to turn off the update of the user interface while running a vba program? Specifically, I am trying to import a series of *.csv files and copy them into the same workbook together. It runs slow and looks bad because you see every action as it goes through the opening and copying procedure. Any ideas would be helpful. Thanks.

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Midlands, UK
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    First line of your macro should be :

    Application.ScreenUpdating = False

    But you must turn it back on at the end :

    Application.ScreenUpdating = True

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Massachusetts, USA
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have used this many times, and found it not to be necessary to add the statement at the end of the macro, seems to work fine. Is this a problem waiting to happen?

  4. #4
    Board Regular
    Join Date
    Apr 2002
    Location
    Midlands, UK
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Not sure. I've also left it off accidently & not had any problems, but as I've been told quite a few times THAT YOU MUST TURN IT BACK ON I didn't want plawton to use it & then find a problem.
    I guess it's just "good practice" to turn things back on after you've turned them off (like calculation ).

  5. #5
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I seldom reset screenupdating back to True.

    You have to know when to do it. Basically, if control gets returned to Excel at the end of the macro, i.e. the code stops running, then there's no need to turn screenupdating back on because Excel will return to default. (i.e. TRUE)

    However, you can get screwed quite easily and this is the only example I have of this.

    Create a userform, doesn't matter what it's called and use this code to show it:



    Application.ScreenUpdating = False
    Userform1.Show 'Or whatever your form is called


    Start moving the form around and you'll be "painting" it all over the screen. This is not necesarily a problem, so long as you know what userform is yours. (ok it is a problem because it's a bug that we've created). This feature is particularly fun when you use "modeless" userforms and use a form to display another.

    Anyway, I hope this helps. (if you're evil, like me, it's also a laugh to alter someone's code to do this, just to see how long it takes them to fix it)

  6. #6
    Board Regular
    Join Date
    Apr 2002
    Location
    Midlands, UK
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I like the cut of your job !

  7. #7
    Board Regular
    Join Date
    Apr 2002
    Location
    Midlands, UK
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ****, that would have been better as Jib

  8. #8
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Yup, that's what the "edit" button's for though.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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