Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is not an answer; like earlier posters I am unable to get this routine to fail.</p> <p>Firstly, I will say this is a dreadful piece of code. I cannot understand why Microsoft posted something this bad. For example:</p> <ul> <li>elapsedTime is not typed. (It should be <code>Dim elapsedTime(2) As Double</code>)</li> <li>i, startTime and stopTime are not defined.</li> <li>The Activate is within the timed block for the first loop so, if Sheet1 is not the active sheet at the beginning, the time to activate it is added to the first loop's duration.</li> <li>The columns are not unhidden between the two loops so the second loop has nothing to do. If you run the routine a second time, the two loops have the same duration.</li> </ul> <p>There is a bug in Excel which I encounter very infrequently and not for a couple of years. When I do encounter it, it takes me so long to discover the cause that I am behind schedule and forget to record the details for next time. There are certain errors for which Excel does not stop and report the fault; instead it terminates the current function and continues with the next statement in the calling routine. This subroutine has been called directly, so it would just stop without finishing.</p> <p>My only suggestion is that there is something about this code on your Sheet1 on your computer that causes this error.</p> <p>You seem to think the <code>Application.ScreenUpdating = True</code> statement is failing. This is possible but unlikely. From your description, all you know is that the routine does not reach the <code>MsgBox</code> statement.</p> <p>I suspect <code>c.Hidden = True</code>. I have seen a question asking about a maximum number of hidden columns but no one knew of a maximum. One answer was you cannot hide part of a merged area but I cannot duplicate that error. Look at your Sheet1: are some even columns hidden but not all? Unhide the columns and try again. Does the routine fail at a consistent column? Does it fail after hiding something like 1,024 columns? </p> <p>I wish you luck with any investigation. However, I suggest you abandon this deadful code and accept that <code>Application.ScreenUpdating = False</code> will reduce the run time of any routine that updates the active worksheet. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload