VBA Ignore Shapes that are Drop Downs

bnstout

New Member
Joined
May 22, 2017
Messages
10
I am trying to count the number of shapes in a given range which has worked fine so far. The code throws an error if I run the code after activating a drop down menu in the sheet.

Dropping down the menu causes the sheet to "add" a shape called "Drop Down 13". My code does not like that and gives me the error "Application-defined or object-defined error"

Here is my code posted below:


Code:
Sub CheckForPrimaryPics()
Cnt = 0
 
For Each shp In ActiveSheet.Shapes

    If Not Application.Intersect(Range("AC13:AQ32"), shp.TopLeftCell) Is Nothing Then Cnt = Cnt + 1
Next



Is there a way that I can ignore this drop down shape in my calculation and only check for Picture shapes? That's what I'm really after.

None of the typical On Error Resume Next or On Error GoTo's have worked for me so far because they defeat the purpose of what the code is trying to do. Count the pictures in the range.

Please let me know if you can help!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try...

Code:
    Dim shp As Shape    
    For Each shp In ActiveSheet.Shapes
        If shp.Type = msoPicture Then
            'etc
        End If
    Next shp

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,451
Members
452,514
Latest member
cjkelly15

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