Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks I'll give it try
"Rick Rothstein" wrote: You can still protect your worksheet and allow the user to select any cells, then use SelectChange to decide if the selection was alright or not. Here is some code that will confine the user's selection to an allowed range; for example, if they click in the allowed range (D4:H8 is the example range implemented in my code below), then you can show your UserForm (replace my MsgBox statement with your own code), otherwise the code below returns the selection to the top left cell of the AllowedRange. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Const AllowedRange As String = "D4:H8" On Error GoTo OnceOnly Application.EnableEvents = False If Not Intersect(Target, Range(AllowedRange)) Is Nothing Then MsgBox "Range OK - You can call show your UserForm" Else With Range(AllowedRange) Cells(.Row, .Column).Select End With End If OnceOnly: Application.EnableEvents = True End Sub -- Rick (MVP - Excel) "ranswrt" wrote in message ... I am try to write a procedure to start a userform when a cell is clicked. I am using the selection change event in the worksheet. I need to keep the cells locked to protect the contents in them. Is there a way to protect the sheet but only allow cells within a range to be selected not all the cell on the worksheet? Or is there another way to have userform start up by clicking or double clicking a cell? Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to select range from active cell range name string | Excel Programming | |||
HELP W/ VBA: SELECT RANGE, ALLCAPS, CELL COLOR, RETURN TO BLANK CELL/PATTERN CELL | Excel Programming | |||
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON | Excel Programming | |||
Select Cell Range | Excel Programming | |||
select last cell in used range | Excel Programming |