Thread: Bad code?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default Bad code?

On Wed, 23 Jul 2008 09:18:38 -0700 (PDT), Spiky
wrote:

Running *any* macro kills the undo stack so you can't undo/repeat. Once
it's done, however, it should be back working, just without any entries from
before the macro was run.


That's what I would expect, and that would be fine. Yet it kills it
til Excel is quit. Of course, I'm trying to duplicate it this morning
for comparison and it isn't happening. But it certainly did yesterday
(and many, many other days), I had to quit Excel to get the
functionality back. So apparently it is not 100% of the time.


Hmm, strange. If you had a Worksheet_Selection change event macro in an
open workbook at the time, it would clear the Undo stack every time you
clicked a cell. Otherwise, I can't think of what might cause that. If you
get any more clues next time it happens, post back.

Maybe doing the Unmerge and Wrap on every cell is causing it. I'm not sure
on that, but see the macro below.


Thanks, I'll try your code, see if it improves. So, UsedRange makes it
work on just cells with data/formatting in them?


Right. Sometimes Excel doesn't reset the UsedRange property and it's bigger
than it needs to be. But it's never smaller and it's almost always smaller
than the whole worksheet.


You probably have an empty module in the workbook. Open the VBE (Alt+F11)
and the Project Explorer (Ctl+R). Make sure there are no modules,
userforms, or class modules in the project. Also, open the Microsoft Excel
Objects (like Sheet1) and make sure there's no code in any of those.


There isn't a module. There are the standard objects, one for each
sheet and the Workbook object. All empty. This only started late last
year. I don't know if the other companies upgraded hardware (I think
I've narrowed that side to Sonicwalls) then, or if it coincided with a
Microsoft update....


You know, that reminds me. I get a file from someone who uses OpenOffice
that gives me a macro warning and there's no evidence of code in it at all.
--
Dick