Roger Govier said:
Hi
Thanks for the feedback letting us know how you got on.
Well done for figuring out the cause of the problem, and solving it
yourself.
<wry grin> Turns out I'm still not so smart, though <sigh>.
I never looked at that code before adding it in initially. So today
when I went to use the workbook, the filters didn't work. Guess what
controls those filters on a protected sheet?!
In fact, this has turned out to be a mess and I doubt I'll be able to
fix it easily. The trouble is that when I've left unprotected
workbooks behind in contracts, they get quite corrupted. I may not be
an expert but I know more than anyone I've come across so far over
many years. Over a year ago I returned back to a place after doing a
contract in between; I'd been gone for only 10 shorts months and my
workbooks were all atrociously deranged! So I learning how to put the
protection code in before and after sorting, etc.
The difficulty with this process is that XL2K doesn't allow filtering
on protected, at least, not without a lot of hassle. When I added
back the filtering code to the workbook that I'd taken out, the awful
flickering returned. Yet the filtering doesn't even work after
pushing a button to re-activate the protection after a sort, for
example.
Yet it's a toss-up. Do I leave the filtering and have an open,
corruptible environment ... or do I remove the filtering, leave all
the unprotect/protect codes in places before and after sorts but the
user can't filter at any of the columns at all. Tough, tough choice.
It's easy with me as I know what to do and even have a button to
unprotect a sheet manually before sorting. I made sure that all the
buttons on the commandbar invoke the protection automatically
afterwards.
Perhaps that might be a possible solution - to add a special unprotect
button for filtering. Trouble with that is the the user might not
really use the buttons enough so the sheet wouldn't necessarily get
protected right after filtering, etc.
I'll have to think about this one. Fortunately I still have about
another 2 weeks before the new person starts and I'll have a few days
to train that person before I finish up myself.
Anyway, here's the code that is supposed to unlock the filtering with
the added anti-flickering code. (This is the code that only unlocks
the filtering till the first protection is put back on.) Perhaps
something might occur to someone here. You're all so much more
advanced than I am and perhaps there's something I don't know re the
filtering:
********************************************************************************
Private Sub Workbook_Open()
Dim I As Integer
For I = 1 To ThisWorkbook.Worksheets.Count
Worksheets(I).Activate
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Protect UserInterfaceOnly:=True
Next I
'-------------------------------------------------------------------------
' code to stop flickering (doesn't work so far).
Application.ScreenUpdating = False
Sheets("LAR Stats").Select
Application.ScreenUpdating = True
'-------------------------------------------------------------------------
End Sub
********************************************************************************
Thanks.

D
--
Regards
Roger Govier
StargateFanFromWork said:
Hi
You could prevent the flicker with
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheets("the sheet to view on opening here").select
Application.ScreenUpdating = True
end sub
[snip]
[snip]