Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry repair router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Excel VBA: Annoying blinking worksheet.

Reply  
Thread Tools
miron_bsz's Avatar
Junior Member with 3 posts.
 
Join Date: Jan 2010
Experience: Intermediate
25-Jan-2010, 01:52 PM #1
Excel VBA: Annoying blinking worksheet.
Hello,

I’am using this simple code to refresh my quary tables:

With Worksheets(“First”)
.Range("A31").QueryTable.Refresh BackgroundQuery:=False
‘worksheet blinks… arrrg
.Range("A31").QueryTable.Refresh BackgroundQuery:=False
‘worksheet blinks… arrrg
.Range("A31").QueryTable.Refresh BackgroundQuery:=False
‘worksheet blinks… arrrg
End with

After each table refresh the worksheet blinks one time. It’s quite annoying. I’d like to have a smooth refreshment. Can anyone please help?
SharksFan's Avatar
Junior Member with 4 posts.
 
Join Date: Jan 2010
Location: Northern California
Experience: Advanced
25-Jan-2010, 04:42 PM #2
You can try to add this line of code before your refresh starts:

Application.ScreenUpdating = False

and then this line at the end:

Application.ScreenUpdating = True

The first line will tell Excel to suspend any screen updates (for as long as it is set to False), and then setting it to True afterwards will allow screen updates to occur again.

Hope this helps...
miron_bsz's Avatar
Junior Member with 3 posts.
 
Join Date: Jan 2010
Experience: Intermediate
27-Jan-2010, 06:58 PM #3
Excel VBA: Annoying blinking worksheet.
Thanks SharksFan!
I’ve changed my code as you suggested. Now it looks like that:

Application.ScreenUpdating = False

With Worksheets(“First”)
.Range("A11").QueryTable.Refresh BackgroundQuery:=False

.Range("A21").QueryTable.Refresh BackgroundQuery:=False

.Range("A31").QueryTable.Refresh BackgroundQuery:=False
End with

Application.ScreenUpdating = True
‘worksheet blinks… arrrg

But now Worksheet blinks at the end after this line “Application.ScreenUpdating = True” is executed. Is it possible to remove completely that annoying blinking effect?
n00bSauce's Avatar
Computer Specs
Junior Member with 24 posts.
 
Join Date: Dec 2009
Location: North Carolina, USA
Experience: Telephony Warrior
28-Jan-2010, 11:35 AM #4
I believe you might be fighting with the nature of the beast here. When you do a refresh, it literally redraws the screen - I don't know that there's a way around that really.

Kudos to SharksFan though for that creative method of blinkage mitigation.
SharksFan's Avatar
Junior Member with 4 posts.
 
Join Date: Jan 2010
Location: Northern California
Experience: Advanced
28-Jan-2010, 03:13 PM #5
I agree with n00bSauce. It's just the way Excel handles QueryTable.Refresh and eventually Excel is going to try to refresh the screen.

Your only other option may be something more drastic (i.e. locking the window from screen updates at a lower level using the Windows API). Here is a link that might shed some light on using this technique:
http://relatedterms.com/thread/20072...%20%20False%20

Not sure if it will work in your case, but just another thought...
maxx_eclipse's Avatar
Computer Specs
Member with 286 posts.
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
29-Jan-2010, 04:08 AM #6
n00bsauce is spot on; It's a similar concept in Access, any refresh requires to essentially reload the whole project, whether it be a worksheet in Excel or a form/datasheet in Access.
nesr's Avatar
Computer Specs
Member with 50 posts.
 
Join Date: Nov 2008
Experience: Advanced
09-Feb-2010, 04:01 AM #7
to eliminate screen blinking let the [Application.ScreenUpdating = True] be at the far end of your code unless it is necessary to update the screen, you can ignore putting it at all, as the Excel will update the screen automatically after executing the whole code.
moreover, try to close the VB editor before running the code, this will speed it up efficiently, and will enhance the program activity.
regards..
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:52 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.