Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does anyone know how to prevent multiple selections on a worksheet? I just
finished putting together some VBA modules that are working very well, when I realized that if the user makes multiple selections (using the control key), then my VBA will break. I would rather not update the code, and in fact the user should never make multiple selections with this particular tool. I would rather just prevent them, if possilble. Thanks in advance, Eric |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am not aware of a way to prevent multiple selections except through code,
so you will have to modify your existing code or add event code (assuming you are doing that now with your existing code) to prevent this. Besides, I doubt whether you would really want to globally restrict multiple selections. What if the user needed to delete several rows of data for some reason (or any other scenario involving multiple cells that doesn't deal directly with your VB code)... would you really want the user to have to delete each cell's content manually, one cell at a time? -- Rick (MVP - Excel) "egun" wrote in message ... Does anyone know how to prevent multiple selections on a worksheet? I just finished putting together some VBA modules that are working very well, when I realized that if the user makes multiple selections (using the control key), then my VBA will break. I would rather not update the code, and in fact the user should never make multiple selections with this particular tool. I would rather just prevent them, if possilble. Thanks in advance, Eric |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you want Selection to be only one cell or only one Area??
If you only want one Area, then: If Selection.Areas.Count 1 Then MsgBox "Cannot do this to a multi-area selection." End If and then terminate the macro. -- Gary''s Student - gsnu200829 "egun" wrote: Does anyone know how to prevent multiple selections on a worksheet? I just finished putting together some VBA modules that are working very well, when I realized that if the user makes multiple selections (using the control key), then my VBA will break. I would rather not update the code, and in fact the user should never make multiple selections with this particular tool. I would rather just prevent them, if possilble. Thanks in advance, Eric |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Should be easy enough to correct.
Wherever you use Selection , change it to Selection.Areas(1). This will return the first-selected contiguous range. -- Tim Zych http://www.higherdata.com Compare data in Excel and find differences with Workbook Compare Free and Pro versions available "egun" wrote in message ... Does anyone know how to prevent multiple selections on a worksheet? I just finished putting together some VBA modules that are working very well, when I realized that if the user makes multiple selections (using the control key), then my VBA will break. I would rather not update the code, and in fact the user should never make multiple selections with this particular tool. I would rather just prevent them, if possilble. Thanks in advance, Eric |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I thank you all for your replies! I know that it's unnatural to restrict
selections like this, but I have my reasons... Anyway, what I did was go into the Worksheet_SelectionChange event, and if the new selection has multiple areas, I put up a msgbox and change the selection back to what it was. Thanks, Eric |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Eric
The usual approach is to adjust the code, not to alarm the user with messageboxes. So your reasons must be of real importance, and they would be of great interest to us fellow developers. Please share. Best wishes Harald "egun" skrev i melding ... I thank you all for your replies! I know that it's unnatural to restrict selections like this, but I have my reasons... Anyway, what I did was go into the Worksheet_SelectionChange event, and if the new selection has multiple areas, I put up a msgbox and change the selection back to what it was. Thanks, Eric |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Multiple Selections | Excel Discussion (Misc queries) | |||
Multiple selections | Excel Discussion (Misc queries) | |||
Validation of multiple selections | Excel Programming | |||
Vlookup for multiple selections | Excel Worksheet Functions | |||
Creating Multiple GIFs from Multiple Range selections -- I need a volunteer to test my code to see why it fails | Excel Programming |