ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   disable range selection (https://www.excelbanter.com/excel-programming/363517-disable-range-selection.html)

[email protected]

disable range selection
 
Hi,
I would like to disable a user's ability to select ranges. I want to
restrict the user to selecting only one cell at a time in certain
worksheets. Is this possible?

Thanks,
Bob


Bob Phillips

disable range selection
 
'-----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'-----------------------------------------------------------------

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Count 1 Then Target.Cells(1, 1).Select
ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ps.com...
Hi,
I would like to disable a user's ability to select ranges. I want to
restrict the user to selecting only one cell at a time in certain
worksheets. Is this possible?

Thanks,
Bob




[email protected]

disable range selection
 
Great, thanks!

Bob Phillips wrote:
'-----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'-----------------------------------------------------------------

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Count 1 Then Target.Cells(1, 1).Select
ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.





--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ps.com...
Hi,
I would like to disable a user's ability to select ranges. I want to
restrict the user to selecting only one cell at a time in certain
worksheets. Is this possible?

Thanks,
Bob




All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com