Need to know what is selected

  • Thread starter Thread starter Maria J-son
  • Start date Start date
M

Maria J-son

Hi,
To a routine, I need to know what is selected on worksheet_change and
worksheet_selectionchange. I need It to take different actions depending on
the type... Selections could be like

Cells
Buttons
CheckBoxes
TextBox
Worksheets
ChartObjects

Most important right now is to find if it is a button selected (in the
shapes collection i think, not OLE). The other types in the list will soon
come to, however.

Can somebody please share a good routine for this?

/Regards
 
Maria

As far as I can see the WorkSheet Selection Change only works with changes
to cells, it doesn't seem to fire as you chose different buttons.
To get around this I suggest you use the GotFocus Event of each object
(TextBox, CommandButton, etc)
Write something into the GotFocus Method that fires a common checking routine
Eg
Private Sub CommandButton1_GotFocus()
Run "MyGeneralCheckingRoutine", "CommandButton1"
End Sub

Your Checking Routine is then being told which Object has been selected and
you can act on that

Hope this helps

Nick
 
Hi and thanks,

I'll look more into how to trig it. Now, more important is the actual
checking routine - how to find out what is selected.

/Regards
 
Objects do not trigger the SelectionChange event, they have their own click
events if OLE objects, or assigned macros if shapes or forms controls, so
you will need to handle them all separately.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Maria

The GotFocus Event is automatically triggered when you select the button by
clicking on it. So, before the Click event fires, the GotFocus should fire.

The "how to find out what is selected." is done by telling your routine what
is selected. Every Object will have its own GotFocus Code - Not just one
for the whole sheet - so each one tells the General Routine which button it
is"
Eg CommandButton1_GorFocus()
Run "MyGeneralCheckingRoutine", "CommandButton1"
Eg CommandButton2_GorFocus()
Run "MyGeneralCheckingRoutine", "CommandButton2"
Eg TextBox1_GorFocus()
Run "MyGeneralCheckingRoutine", "TextBox1"
Eg CommandButton3_GorFocus()
Run "MyGeneralCheckingRoutine", "CommandButton3"

Nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top