Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everyone,
Using VBA, how may i stop more than one cell being selected in a sheet? Thanks John |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi John
Put this in the sheet's module: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Target(1).Select End Sub HTH. Best wishes Harald "John" skrev i melding ... Hi everyone, Using VBA, how may i stop more than one cell being selected in a sheet? Thanks John |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"John" skrev i en meddelelse
... Hi everyone, Using VBA, how may i stop more than one cell being selected in a sheet? Thanks John Hi John Here's one way: 1. Go to the VBA editor with <Alt<F11 2. Double-click "ThisWorkbook" 3. Copy and paste the below code. Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Range) 'Leo Heuser, 17 Nov. 2006 If Selection.Cells.Count 1 Then MsgBox "Please select only one cell." ActiveCell.Select End If End Sub That will work for all sheets in the workbook. If you only want it to work for a single sheet, you may doubleclick the sheets code module instead and use this code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Leo Heuser, 17 Nov. 2006 If Selection.Cells.Count 1 Then MsgBox "Please select only one cell." ActiveCell.Select End If End Sub -- Best regards Leo Heuser Followup to newsgroup only please. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Howard, Leo,
Thanks, works perfect John "Leo Heuser" wrote: "John" skrev i en meddelelse ... Hi everyone, Using VBA, how may i stop more than one cell being selected in a sheet? Thanks John Hi John Here's one way: 1. Go to the VBA editor with <Alt<F11 2. Double-click "ThisWorkbook" 3. Copy and paste the below code. Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Range) 'Leo Heuser, 17 Nov. 2006 If Selection.Cells.Count 1 Then MsgBox "Please select only one cell." ActiveCell.Select End If End Sub That will work for all sheets in the workbook. If you only want it to work for a single sheet, you may doubleclick the sheets code module instead and use this code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Leo Heuser, 17 Nov. 2006 If Selection.Cells.Count 1 Then MsgBox "Please select only one cell." ActiveCell.Select End If End Sub -- Best regards Leo Heuser Followup to newsgroup only please. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"John" skrev i en meddelelse
... Howard, Leo, Thanks, works perfect John You are welcome. Thanks for the feedback. Howard????????? Leo Heuser |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select multiple adjacent cells of multiple cells without selecting | New Users to Excel | |||
Select multiple adjacent cells of multiple cells without selecting | Excel Worksheet Functions | |||
Prevent Users from Selecting Cells | Excel Worksheet Functions | |||
Prevent selecting locked cells | Excel Programming | |||
Can I prevent users selecting multiple cells? | Excel Programming |