Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Prevent selecting multiple cells

Hi everyone,

Using VBA, how may i stop more than one cell being selected in a sheet?

Thanks

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Prevent selecting multiple cells

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default Prevent selecting multiple cells

"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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Prevent selecting multiple cells

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default Prevent selecting multiple cells

"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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs New Users to Excel 11 December 24th 09 01:09 AM
Select multiple adjacent cells of multiple cells without selecting sjsjsjsjsjs Excel Worksheet Functions 7 December 23rd 09 08:54 PM
Prevent Users from Selecting Cells Excel User Excel Worksheet Functions 1 March 2nd 06 01:17 AM
Prevent selecting locked cells Andy Excel Programming 6 October 14th 04 01:41 PM
Can I prevent users selecting multiple cells? Angus Comber[_2_] Excel Programming 4 November 7th 03 09:36 AM


All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"