Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Preventing Multiple Selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Preventing Multiple Selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Preventing Multiple Selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Preventing Multiple Selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Preventing Multiple Selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Preventing Multiple Selections

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
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
Copy Multiple Selections dford Excel Discussion (Misc queries) 2 September 14th 07 07:07 AM
Multiple selections Confuddled User!!!!!!!!!!!!! Excel Discussion (Misc queries) 3 August 30th 07 08:56 PM
Validation of multiple selections Mark Excel Programming 2 May 9th 07 09:37 PM
Vlookup for multiple selections Billing Goddess Excel Worksheet Functions 7 April 10th 06 05:40 PM
Creating Multiple GIFs from Multiple Range selections -- I need a volunteer to test my code to see why it fails Father Guido[_5_] Excel Programming 0 November 19th 05 08:52 AM


All times are GMT +1. The time now is 03:50 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"