change colour of picture based on cell value

mickyflash

Board Regular
Joined
Jan 29, 2009
Messages
77
hello again guys

I have found this video of Bills that explains how I could dynamically change the .width & .Height of a shape in excel, but I am struggling to convert this to the shapes colour?

There would be only 2 options, if the linked cell is = to TRUE to view the picture In colour, or greyscale if FALSE

Thanks in advance for your help
 
Going back to your original code what is the name given by Excel to the image inserted in E4 ?
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
With "Picture 1" in the cell E2 what happens when you run this code ?
VBA Code:
Sub ChangeColour()
    ActiveSheet.Shapes("Picture 1").PictureFormat.ColorType = 2
End Sub2
 
Upvote 0
Then this should work

Go back to your ORIGINAL code

1.
add this as declaration with others at top of module
Code:
Dim pic As Variant

2.
Below: URL.Parent.Pictures.Insert URL.Value
insert:
VBA Code:
    Set pic = URL.Parent.Shapes(URL.Parent.Shapes.Count)
    If Not URL.Offset(, 1) Then pic.ColorType = 2
 
Upvote 0
Thank you again for trying so much.. BUT

using this code:
Capture2.PNG

I am still getting a 'object does not suport this property or method' debug error when the cell value is FALSE.
works OK when TRUE
 
Upvote 0
oops .. :eek:

✖BAD:
VBA Code:
pic.ColorType = 2
✔GOOD:
VBA Code:
pic.PictureFormat.ColorType = 2
 
Upvote 0
After this line
VBA Code:
Set Pic = URL.Parent.Pictures.Insert(URL.Value)
Insert this line
VBA Code:
MsgBox Pic.Name

what does the message box return
 
Upvote 0

Forum statistics

Threads
1,215,466
Messages
6,124,983
Members
449,201
Latest member
Lunzwe73

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