ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deselect two objects after all selected (https://www.excelbanter.com/excel-programming/306333-deselect-two-objects-after-all-selected.html)

Cutter[_14_]

Deselect two objects after all selected
 
Hello

Each week I copy a list of data from a web page and paste it into a
Excel worksheet. The data, However, includes dozens of small graphi
objects which I don't want so I have to delete them. I do this b
EditGo ToSpecialObjects to select all objects on the sheet but
have to deselect two objects before hitting delete. I tried recordin
a macro for this but instead of showing a way to deselect the tw
objects it listed all of the others.

Is there a VBA equivalent to holding the shift key and clicking on th
two objects to deselect them from the selection? The two objects fo
deselection are named Picture 1 and Picture 2.

Thanks for any help you might have

--
Message posted from http://www.ExcelForum.com


Myrna Larson

Deselect two objects after all selected
 
I don't know of any way to "deselect" something other than by selecting
something else.

I believe you need to use a loop to delete just the pictures you want. It
might look something like this:

Sub Macro1()
Dim Obj As Object
For Each Obj In ActiveSheet.DrawingObjects
Select Case Obj.Name
Case "Picture1", "Picture2"
'don't do anything
Case Else
Obj Delete
End Select
Next Obj
End Sub

PS: I used the macro recorder to get the code for selecting the objects on the
sheet. The line referred to ActiveSheet.DrawingObjects. When I put the cursor
on that word and pressed F1 to get help on the properties and methods, I got a
message about it being a hidden object, with no help available.


On Sat, 7 Aug 2004 19:25:28 -0500, Cutter
wrote:

Hello

Each week I copy a list of data from a web page and paste it into an
Excel worksheet. The data, However, includes dozens of small graphic
objects which I don't want so I have to delete them. I do this by
EditGo ToSpecialObjects to select all objects on the sheet but I
have to deselect two objects before hitting delete. I tried recording
a macro for this but instead of showing a way to deselect the two
objects it listed all of the others.

Is there a VBA equivalent to holding the shift key and clicking on the
two objects to deselect them from the selection? The two objects for
deselection are named Picture 1 and Picture 2.

Thanks for any help you might have.


---
Message posted from http://www.ExcelForum.com/



Myrna Larson

Deselect two objects after all selected
 
Oops, I see a typo. The dot is missing between Obj and Delete, i.e. it should
be

Sub Macro1()
Dim Obj As Object
For Each Obj In ActiveSheet.DrawingObjects
Select Case Obj.Name
Case "Picture1", "Picture2"
'don't do anything
Case Else
Obj.Delete '<<<< ERROR HERE IN 1ST POST
End Select
Next Obj
End Sub


On Sat, 07 Aug 2004 19:47:07 -0500, Myrna Larson
wrote:

I don't know of any way to "deselect" something other than by selecting
something else.

I believe you need to use a loop to delete just the pictures you want. It
might look something like this:

Sub Macro1()
Dim Obj As Object
For Each Obj In ActiveSheet.DrawingObjects
Select Case Obj.Name
Case "Picture1", "Picture2"
'don't do anything
Case Else
Obj Delete
End Select
Next Obj
End Sub

PS: I used the macro recorder to get the code for selecting the objects on

the
sheet. The line referred to ActiveSheet.DrawingObjects. When I put the cursor
on that word and pressed F1 to get help on the properties and methods, I got

a
message about it being a hidden object, with no help available.


On Sat, 7 Aug 2004 19:25:28 -0500, Cutter
wrote:

Hello

Each week I copy a list of data from a web page and paste it into an
Excel worksheet. The data, However, includes dozens of small graphic
objects which I don't want so I have to delete them. I do this by
EditGo ToSpecialObjects to select all objects on the sheet but I
have to deselect two objects before hitting delete. I tried recording
a macro for this but instead of showing a way to deselect the two
objects it listed all of the others.

Is there a VBA equivalent to holding the shift key and clicking on the
two objects to deselect them from the selection? The two objects for
deselection are named Picture 1 and Picture 2.

Thanks for any help you might have.


---
Message posted from http://www.ExcelForum.com/



Cutter[_15_]

Deselect two objects after all selected
 
Myrna

Thank you very much for your reply. I'll give it a try

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com