VBA Module Picture Check

JBRKiwi

New Member
Joined
Feb 3, 2017
Messages
1
Hi,

Having a little bit of a problem with building a VBA module code that will detect if a certain picture is being used within a cell. Ive got to a point where the code will recognise if a picture is being displayed but cannot differentiate between the two picture references and so will always display TRUE.

I need the code to recognise that any picture with the picture reference of "YES_#####" (random numbers) is displayed as TRUE and anything else will return as a FALSE value.

Below is the code as it stands at the moment. I'm extremely new to VBA code so I am struggling massively here, and any help would be extremely appreciated.

Dim bResult As Boolean
bResultPic = False

If Not ActiveSheet.Shapes Is Nothing Then
For Each shp In ActiveSheet.Shapes
If shp.TopLeftCell.Address = Target.Address "*YES_" _
And shp.BottomRightCell.Address = Target.Address "*YES_" Then
bResultPic = True
End If
Next shp

End If
HasImage = bResultPic
End Function
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Need more info

TopLeftCell.Address is the cell address the pic is attached to e.g. cell A1 has an address of "A1"

What is this Target.Address?

What code calls the function?

Is the picture reference the Pic name?

Your lopping through all shapes, how are multiple shapes to be handles?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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