Change Glow each time picture is clicked

FootBallBat

Board Regular
Joined
Jan 26, 2012
Messages
169
I'm creating a score keeping spreadsheet for game night.
I have 2 images below. What I am looking for is: I want to be able to click an image (card) and it adds a glow, then when you click it again the glow disappears.
I know how to assign a macro to an image but do not know how to do an "if" statement so that if it has a glow it removes it when clicked.
P.S. If this is to complex I am willing to change it, I mainly just want a way to click on the cards you have in your hand and they highlight in a way that is easy to see (like if your grandparents were looking at it lol)

Here is the macro I asigned for the glow to be added:
Sub Change_Color()
ActiveSheet.Shapes.Range(Array("Picture 117")).Select
With Selection.ShapeRange.Glow
.Color.RGB = RGB(0, 176, 240)
.Transparency = 0
.Radius = 10
End With
End Sub
https://drive.google.com/open?id=1uCN5qzzNzlww4iHwyhrE7ihGlAKlA5Xr
https://drive.google.com/open?id=1-SSNNgBa-8k9hl5j2_3DEOFqwsMWpcMt
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Maybe this....
Code:
Sub Change_Color()
For Each Shape In ActiveSheet.Shapes
Shape.Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
    With ActiveSheet.Shapes.Range(Array("Picture 2")).ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub
 
Upvote 0
Run-time error '438':
Object doesn't support this property or method

Sub Change_Color()
For Each Shape In ActiveSheet.Shapes
Shape.Select
With Selection.ShapeRange.Glow
.Color.RGB = RGB(0, 0, 0)
.Radius = 0
End With
Next
ActiveSheet.Shapes.Range(Array("Picture 117")).Select
With ActiveSheet.Shapes.Range(Array("Picture 117")).ShapeRange.Glow
.Color.RGB = RGB(0, 176, 240)
.Radius = 10
End With
End Sub
 
Upvote 0
Sorry, I was playing with the syntax.....
Code:
Sub Change_Color()
For Each Shape In ActiveSheet.Shapes
Shape.Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub
 
Upvote 0
Sorry, I was playing with the syntax.....
Code:
Sub Change_Color()
For Each Shape In ActiveSheet.Shapes
Shape.Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub


Well it adds the glow, but it does not take it away at all :(
 
Upvote 0
If you step through the code does it Select the shape ??
 
Upvote 0
If you step through the code does it Select the shape ??

I just stepped through the code and it selects a random image out of all of them. As soon as it hits Next it jumps back to the top.
I only want it to glow when the picture is clicked on. If I have to create a separate macro to all of them I'm fine with that as well.
 
Upvote 0
The first half of the code clears ALL glows by stepping through each image

Code:
For Each Shape In ActiveSheet.Shapes
Shape.Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next

The second half selects the picture in your code ( in this case Picture 2) and adds the glow

Code:
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
    With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub
 
Upvote 0
Ok, this worked fine for me....remeber the first half of the code clears ALL glows ready for the new selection !!

Code:
Option Explicit
Sub Change_Color()
Dim shape As shape, nu As shape
Set nu = ActiveSheet.Shapes(Selection.Name)
For Each shape In ActiveSheet.Shapes
shape.Select
With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next
nu.Select
With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub
 
Upvote 0
Ok, this worked fine for me....remeber the first half of the code clears ALL glows ready for the new selection !!

Code:
Option Explicit
Sub Change_Color()
Dim shape As shape, nu As shape
Set nu = ActiveSheet.Shapes(Selection.Name)
For Each shape In ActiveSheet.Shapes
shape.Select
With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 0, 0)
        .Radius = 0
    End With
Next
nu.Select
With Selection.ShapeRange.Glow
        .Color.RGB = RGB(0, 176, 240)
        .Radius = 10
    End With
End Sub

Ok I understand now.
I am running an issue im having.
The code works, it just ran so fast I did not realize it was removing the glow then added it instantly.
So the problem Im having is that I click on a card it removes all glow from every card then adds glow to just the one card I clicked on.
So in the game I took a screenshot of I will have 20 cards in my hand, so I would like to be able to click on all 20 cards and add a glow to them before wiping the glow from all the cards.
Sorry if this is an easy fix I just never worked on a glow before.
Is it at all possible to set up the code to work with just the image I click on? That way I can create a macro for all cards. Thanks
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top