PDA

View Full Version : [SOLVED] Assigning two macros to one shape to run on different actions



rosalie
10-24-2017, 07:30 AM
Hi everyone,
It's my first post here (woo) so please bear with me if I don't get this right!

Basically I want to assign two macros to one shape, one that will run on a single click (as per usual) and one that will run on something else such as a double click or right click.

I've tried looking into events and the worksheet_beforedoubleclick event but am really struggling to assign it to the shape.

Does anyone have any advice/ done this before?

Thanks in advance!!

Jan Karel Pieterse
10-24-2017, 07:41 AM
SHapes can only respond to one assigned macro which runs at click. If you need more "events, add an ActiveX control to your sheet, which have a number of events available such as mouseup/down, keyup/down, mousemove, right-click, click, ...

Paul_Hossler
10-24-2017, 07:55 AM
The easiest way I know would be to click the shape holding down a shift key or not holding down a shift key

As Jan said, the shape can only respond to one macro, but THAT macro can respond to shift key status




Sub ShapeMacro()
If IsShiftKeyDown Then
Macro1
Else
Macro2
End If
End Sub


Sub Macro1()
MsgBox "Shift Key macro"
End Sub


Sub Macro2()
MsgBox "Not Shift Key macro"
End Sub




The rest of the code is in the attachment (not original with me, but I didn't make a reference where I 'borrowed' it so apologies to the originator)

p45cal
10-24-2017, 07:56 AM
so please bare with me if I don't get this right!I'll keep my clothes on if that's all right.

rosalie
10-24-2017, 08:04 AM
:banghead: oops my bad!

rosalie
10-24-2017, 08:15 AM
Thank you so Paul much this absolutely worked!!!