Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
weird focus problem
Hi Taher
I always use a select line with this kind off code See this example for all sheets in the workbook Private Sub Workbook_Open() Dim Sh As Worksheet Application.ScreenUpdating = False For Each Sh In ThisWorkbook.Worksheets Sh.Select Sh.Protect userinterfaceonly:=True Sh.EnableSelection = xlUnlockedCells Next Sheets(1).Select Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Taher Baderkhan" wrote in message ... Hi, I am using a worksheet which I called "Input" as a form. I am allowing the user to input data only in the cells that are unlocked. I am protecting the worksheet on initialization of the workbook using the following VBA code: Set ws = ActiveWorkbook.Worksheets("Input") ws.EnableSelection = xlUnlockedCells ws.Protect UserInterfaceOnly:=True if the user opens up the workbook and the "Input" worksheet is the active sheet then everything works as expected. However, if the active sheet is not the "Input" worksheet and then through the code I attempt to activate the "Input" sheet and select any cell then the focus border seems to either disappear or freeze. It does not matter whether the cell I am attempting to select is locked or not. If I run the code that set the protection for the "Input" sheet again the focus problems gets fixed. If I activate another sheet and then reactivate the "Input" sheet through the code (basically, trying to regenerate the problem) the focus seems to work just fine. I have realized that this problem exists only when you try it the first time. To regenerate the problem I had to shut down excel and reopen the workbook. I tried to play with the UseInterfaceOnly by trying different combinations but the problem seemed to persist. The workaround I found Thus far is to run ws.EnableSelection = xlNoRestrictions, Activate the "Input" sheet and then run ws.EnableSelection = xlUnlockedCells. Is there any better solution? Taher |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
weird problem | Setting up and Configuration of Excel | |||
Weird Problem | Excel Worksheet Functions | |||
cmdbarmenu focus problem | Excel Worksheet Functions | |||
Weird problem | Excel Worksheet Functions | |||
Weird Problem | Excel Worksheet Functions |