Select Objects on worksheet based on size

mrvain

New Member
Joined
Sep 28, 2011
Messages
3
Hi,

I would like to know if it is possible with VBA in Excel 2007 to select objects based on size (or above a certain size).

I would like to select all the picture objects but not the small checkboxes on my worksheet.

I know that I can select the items one by one with home -> find/select -> select object but I would appreciate if I could make this "find/select" conditional.

with kind regards,

M<M>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi
Welcome to the board

Can you explain what you want to do? You can select objects in vba, but it's rare that you need to. If we know what you need maybe we can help.
 
Upvote 0
Yes, it is possible to discrimnate by size, but
I would like to select all the picture objects but not the small checkboxes on my worksheet.<m>
rather than worry about size, consider type:
</m>
Code:
Sub blah()
ActiveCell.Select 'to deselect any shapes
For Each shp In ActiveSheet.Shapes
  If shp.Type = msoPicture Then shp.Select False
Next shp
End Sub
<m>pgc makes an important point.
</m>
 
Last edited:
Upvote 0
Remark: if you really want to select all the pictures in the active worksheet you can also use:

Code:
ActiveSheet.Pictures.Select

but, as I said, you don't usually select objects in vba.
 
Last edited:
Upvote 0
Remark: if you really want to select all the pictures in the active worksheet you can also use:

Code:
ActiveSheet.Pictures.Select
but, as I said, you don't usually select objects in vba.
I tried this before I posted - (in excel 2003) it selects activeX checkboxes too!
 
Upvote 0
I tried this before I posted - (in excel 2003) it selects activeX checkboxes too!

Hi p45cal

Thank you for the information. I did not know that that would happen.


Mrvain, sorry, please disregard my last post.
 
Upvote 0
Dear Guru's

Thank you for your reply. As an amateur and not enough programming experience (= inventing the wheel every time again) it is difficult to make clear what you want but the pointers I got from you solved my issue. I can now discriminated between picture sizes in the selection.

code:

Sub blah()
ActiveCell.Select 'to deselect any shapes
For Each shp In ActiveSheet.Shapes
If shp.Width < 10 Then shp.Select False
Next shp
End Sub

With kind regards,

M.
 
Upvote 0

Forum statistics

Threads
1,223,725
Messages
6,174,134
Members
452,546
Latest member
Rafafa

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