Hello again gang,
Let's see if I can explain this quirk correctly.....I've posted all the code
involved below.
Here's what it's supposed to do:
On UF2 there are 52 buttons, by clicking on any one of them you are taken to
the "Data" sheet. Then that sheet is split and certain columns are hidden,
depending upon the button selected on UF2. This allows the OP to see what he
needs to see and enter data only in the cells that are unlocked. When the
"Save Data" button on "Data" sheet is clicked all Cols are unhidden and the
WB is saved and you are returned to UF2. This all works well, most of the
time, however occassionally, after the button click on UF2, the program
flashes and returns you to UF2. By clicking again on the button (sometimes
it takes 3-4 clicks) the program will finally land on the "Data" sheet as
it's supposed to. When this happens, no error msgs appear and it appears to
do no harm to the WB, but it is very aggravating. It's also difficult to
reproduce, as it only happens infrequently. Any help would be greatly
appreciated in cornering this bug.
The Layout:
On "Data" sheet:
Cols "A,B,C" are locked
Rows "1,2" are locked
All other cells are unlocked
There is a Button ("Save Data") that resides over cells B2:C2
The below Sub Jul05 is reached through a button click on a form UF2 that I
developed.
There are 52 Subs that Call SplitDataSheet and then hide various Cols.
Sub Jul05()
Call SplitDataSheet
Columns("G:IV").Select
Selection.EntireColumn.Hidden = True
Range("D3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Sub SplitDataSheet()
Sheets("DATA").Select
ActiveSheet.Unprotect
Columns("A:IV").Select
Selection.EntireColumn.Hidden = False
Range("D3").Select
ActiveWindow.FreezePanes = True
End Sub
The "Save Data" button has the following code:
Sub SaveData()
ActiveSheet.Unprotect
Columns("A:IV").Select
Selection.EntireColumn.Hidden = False
ActiveWindow.FreezePanes = False
Range("A1").Select
MsgBox "Workbook Will Now Be Saved!"
ActiveWorkbook.Save
UF2.Show
End Sub
I hope that's enough info to find this bug.....appreciate any help here,
Don
Bookmarks