Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Worksheet_SelectionChange allow multiple ranges to be selected

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet_SelectionChange allow multiple ranges to be selected

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Worksheet_SelectionChange allow multiple ranges to be selected

As the ctrl key needs to be held down to select non-contiguious cells I would
have thought it could detect the ctrl key position
So, taking finger off the ctrl key could be the indicator.

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet_SelectionChange allow multiple ranges to be selected

That doesn't trigger an event.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

As the ctrl key needs to be held down to select non-contiguious cells I would
have thought it could detect the ctrl key position
So, taking finger off the ctrl key could be the indicator.

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Worksheet_SelectionChange allow multiple ranges to be selected

I was sure I had done this, but maybe it was only when testing and it failed
leaving Events turned off.
Can I test for ctrl key down in my event?
Then I can control whether to display my form.

Thanks

"Tom Ogilvy" wrote:

That doesn't trigger an event.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

As the ctrl key needs to be held down to select non-contiguious cells I would
have thought it could detect the ctrl key position
So, taking finger off the ctrl key could be the indicator.

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet_SelectionChange allow multiple ranges to be selected

You can test for it, but you just said it would be down.

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long)
As Integer

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
'To check wheteher Control key is pressed
If GetAsyncKeyState(17) Then
MsgBox "Control key pressed"
End If
End Sub


--
Regards,
Tom Ogilvy

"Graham Y" wrote:

I was sure I had done this, but maybe it was only when testing and it failed
leaving Events turned off.
Can I test for ctrl key down in my event?
Then I can control whether to display my form.

Thanks

"Tom Ogilvy" wrote:

That doesn't trigger an event.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

As the ctrl key needs to be held down to select non-contiguious cells I would
have thought it could detect the ctrl key position
So, taking finger off the ctrl key could be the indicator.

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Worksheet_SelectionChange allow multiple ranges to be selected

OK so the event actually fires when I click the mouse in a cell, at which
point ctrl must be down, I had thought the event fired when I let go of the
mouse, so it looks like I'll have to add a toolbar or something.

Thanks for you help

"Tom Ogilvy" wrote:

You can test for it, but you just said it would be down.

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long)
As Integer

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
'To check wheteher Control key is pressed
If GetAsyncKeyState(17) Then
MsgBox "Control key pressed"
End If
End Sub


--
Regards,
Tom Ogilvy

"Graham Y" wrote:

I was sure I had done this, but maybe it was only when testing and it failed
leaving Events turned off.
Can I test for ctrl key down in my event?
Then I can control whether to display my form.

Thanks

"Tom Ogilvy" wrote:

That doesn't trigger an event.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

As the ctrl key needs to be held down to select non-contiguious cells I would
have thought it could detect the ctrl key position
So, taking finger off the ctrl key could be the indicator.

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Worksheet_SelectionChange allow multiple ranges to be selected

Another thought
If I make the form non modal I can select extra cells, but I'm not sure how
to get the info onto my form.
Currently I load the dates (determined by which column the selected cells
are in) into an array, sort it, and then display on my form, to show these
are the dates that will be affected by the form.
How can I re-evaluate which cells are selected?

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet_SelectionChange allow multiple ranges to be selected

I would guess an update button on the form. When clicked, the code executes
to refresh/revise/update the list.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

Another thought
If I make the form non modal I can select extra cells, but I'm not sure how
to get the info onto my form.
Currently I load the dates (determined by which column the selected cells
are in) into an array, sort it, and then display on my form, to show these
are the dates that will be affected by the form.
How can I re-evaluate which cells are selected?

"Tom Ogilvy" wrote:

How would excel know you have stopped selecting cells?

Events don't fire when you don't do anything.

--
Regards,
Tom Ogilvy


"Graham Y" wrote:

I have an input form that pops up when a user selectes a cell, but I want
them to be able to use ctrl to pick non-contiguious cells, but as soon as I
let go of the mouse button, to select the next cell, the form pops up.
I know I've done this before because I have put code in to check the range
of columns selected, which I have tested.

Any Ideas how I stop the form poping up until I have stopped selecting cells?

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Worksheet_SelectionChange allow multiple ranges to be selected

Tom wrote:
<<Events don't fire when you don't do anything.

In Excel 2000, the Worksheet_SelectionChange event fires every time you
change anything about the selection.
For example, say cell $A$1 is currently selected. As soon as you press
the shift key and extend the range to include cell $B$2, the
Worksheet_SelectionChange event fires. If you then press the Ctrl key to
add another cell (say cell $D$5), the Worksheet_SelectionChange event
fires again. It fires again when you press the shift key to extend the
2nd area of the selection.
--
Regards,
Bill Renaud





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Worksheet_SelectionChange allow multiple ranges to be selected

Ignore my previous post. I had my newsreader in non-grouped mode
momentarily while checking something else, and didn't see the rest of
the thread.
--
Regards,
Bill Renaud



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
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
Macro to name ranges for selected worksheets carl Excel Programming 3 January 13th 06 04:10 PM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM
Using selected ranges ksnapp[_8_] Excel Programming 3 February 27th 04 08:33 PM


All times are GMT +1. The time now is 09:11 PM.

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

About Us

"It's about Microsoft Excel"