ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Executing a macro from pressing a shape (https://www.excelbanter.com/excel-programming/340352-executing-macro-pressing-shape.html)

Gwen[_3_]

Executing a macro from pressing a shape
 
Hello,

I have written a macro that changes the color of a shape (rectangle 1) when
I press on my shape.
I assign the macro to that shape.

I the macro I have :
ActiveSheet.shapes("rectangle 1").select
if Selection.shaperange.fill....etc. then
end if

Now I want to assign this macro to run on any other shapes in my sheet.
But it only execute for shapes("rectangle 1").

Any suggestion?

Thanks



Norman Jones

Executing a macro from pressing a shape
 
Hi Gwen,

Try something like:

'=====================
Public Sub ToggleColor()
With ActiveSheet.Shapes(Application.Caller).Fill.ForeCo lor
If .SchemeColor = 4 Then
.SchemeColor = 3
Else
.SchemeColor = 4
End If
End With
End Sub

'<<=====================


---
Regards,
Norman



"Gwen" wrote in message
. ..
Hello,

I have written a macro that changes the color of a shape (rectangle 1)
when I press on my shape.
I assign the macro to that shape.

I the macro I have :
ActiveSheet.shapes("rectangle 1").select
if Selection.shaperange.fill....etc. then
end if

Now I want to assign this macro to run on any other shapes in my sheet.
But it only execute for shapes("rectangle 1").

Any suggestion?

Thanks





All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com