Statusbar / Screen display - out of sync

dwooldridge

New Member
Joined
Dec 1, 2011
Messages
18
OK, this is a bit weird. In Excel 2007. I want a light-weight way to show progress while I read a bunch of data from the database. The process is this: The user presses a button (ActiveX control) on the worksheet. We go to VBA code that calls a bunch of subs to read data:

private sub btnReadData_Click()

call suba
call subb
call subc
call subd

end sub

So I hit upon this idea. At the start of 'btnReadData_Click' change the color of the button. At the start of each 'suba', 'subb', etc. write a message to the status bar telling what we are doing. After the last 'subd' is execute change the button color back to its original color. So we have:

private sub btnReadData_Click()

btnReadData.backcolor = green ' I use some hex constant to set to green

call suba
call subb
call subc
call subd

btnReadData.backcolor = vbButtonFace ' Or whatever the constant is to set to std. button color

end sub

Here's the interesting thing. The first time I press the button it turns green, status messages popup, and then the button color goes back to standard color - great! On subsequent executions it 'appears' that the button turns green, status messages start being output, the button goes back to the original color, status messages continue to be output and eventually we are done.

Its like the button color change is asynchronous - it changes back too early! Anybody ever see this kind of behavior before? I don't believe 'screenupdating' is being turned off/on anywhere. I tried DoEvents but that didn't seem to have any impact. The two backcolor statements I show above are the only ones in the code.

Very odd.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top