Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default select and delete all pictures in a given range

I would like to be able to have VBA for excel delete all the pictures on a
given worksheet, but only in a certain range of that sheet. Is this possible?
ie. delete the pictures found only in the range A5:C25

Worksheets("Sheet2").Range("A5:C25").Shapes.Select All
Selection.Delete

'That baby doesn't work, but is there perhaps something similar that might
do the trick?

Any help is appreciated,

Thanks!

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default select and delete all pictures in a given range

Pictures "float" above the cells.

But you can find if they "hide" cells:

http://groups.google.com/group/micro...539a3aca31dcd7
--
Gary''s Student - gsnu200765


"the excel-arator" wrote:

I would like to be able to have VBA for excel delete all the pictures on a
given worksheet, but only in a certain range of that sheet. Is this possible?
ie. delete the pictures found only in the range A5:C25

Worksheets("Sheet2").Range("A5:C25").Shapes.Select All
Selection.Delete

'That baby doesn't work, but is there perhaps something similar that might
do the trick?

Any help is appreciated,

Thanks!

John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default select and delete all pictures in a given range

Delete all pictures partly or entirely within A5:C25 on Sheet2 of
activeworkbooik -

Sub test()
Dim s As String
Dim pic As Picture
Dim rng As Range

' Set ws = ActiveSheet
Set ws = ActiveWorkbook.Worksheets("Sheet2")

Set rng = ws.Range("A5:C25")

For Each pic In ActiveSheet.Pictures
With pic
s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
End With
If Not Intersect(rng, ws.Range(s)) Is Nothing Then
pic.Delete
End If
Next

End Sub

Regards,
Peter T

"the excel-arator" wrote in
message ...
I would like to be able to have VBA for excel delete all the pictures on a
given worksheet, but only in a certain range of that sheet. Is this

possible?
ie. delete the pictures found only in the range A5:C25

Worksheets("Sheet2").Range("A5:C25").Shapes.Select All
Selection.Delete

'That baby doesn't work, but is there perhaps something similar that might
do the trick?

Any help is appreciated,

Thanks!

John



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default select and delete all pictures in a given range

Just what I needed, thanks!

"Peter T" wrote:

Delete all pictures partly or entirely within A5:C25 on Sheet2 of
activeworkbooik -

Sub test()
Dim s As String
Dim pic As Picture
Dim rng As Range

' Set ws = ActiveSheet
Set ws = ActiveWorkbook.Worksheets("Sheet2")

Set rng = ws.Range("A5:C25")

For Each pic In ActiveSheet.Pictures
With pic
s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
End With
If Not Intersect(rng, ws.Range(s)) Is Nothing Then
pic.Delete
End If
Next

End Sub

Regards,
Peter T


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select and delete all pictures in a given range

On Jan 17, 5:17 pm, "Peter T" <peter_t@discussions wrote:
Delete all pictures partly or entirely within A5:C25 on Sheet2 of
activeworkbooik -

Sub test()
Dim s As String
Dim pic As Picture
Dim rng As Range

' Set ws = ActiveSheet
Set ws = ActiveWorkbook.Worksheets("Sheet2")

Set rng = ws.Range("A5:C25")

For Each pic In ActiveSheet.Pictures
With pic
s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
End With
If Not Intersect(rng, ws.Range(s)) Is Nothing Then
pic.Delete
End If
Next

End Sub

Regards,
Peter T

"the excel-arator" wrote in
...

I would like to be able to have VBA for excel delete all the pictures on a
given worksheet, but only in a certain range of that sheet. Is this

possible?
ie. delete the pictures found only in the range A5:C25


Worksheets("Sheet2").Range("A5:C25").Shapes.Select All
Selection.Delete


'That baby doesn't work, but is there perhaps something similar that might
do the trick?


Any help is appreciated,


Thanks!


John


perfect one!! kudos to your knowledge.. this worked perfect for me
too!!! Hip hip hurray!!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default select and delete all pictures in a given range

see important correction below -

wrote in message
...
On Jan 17, 5:17 pm, "Peter T" <peter_t@discussions wrote:
Delete all pictures partly or entirely within A5:C25 on Sheet2 of
activeworkbooik -

Sub test()
Dim s As String
Dim pic As Picture
Dim rng As Range

' Set ws = ActiveSheet
Set ws = ActiveWorkbook.Worksheets("Sheet2")

Set rng = ws.Range("A5:C25")

For Each pic In ActiveSheet.Pictures
With pic
s = .TopLeftCell.Address & ":" & .BottomRightCell.Address
End With
If Not Intersect(rng, ws.Range(s)) Is Nothing Then
pic.Delete
End If
Next

End Sub

Regards,
Peter T


<snip

perfect one!! kudos to your knowledge.. this worked perfect for me
too!!! Hip hip hurray!!


And now two satisfied customers....

But after a glance at the code as posted I regret to advise there is an
error. It would only become apparent if not dealing with the activesheet.

Please change
For Each pic In ActiveSheet.Pictures
to
For Each pic In ws.Pictures

Regards,
Peter T





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select a range of rows to delete Donna[_3_] Excel Worksheet Functions 2 January 26th 10 07:32 PM
Select Data by Date Range, Delete Rest Learner Excel Programming 2 January 21st 07 03:42 AM
delete pictures VilMarci Excel Programming 2 February 18th 05 09:56 AM
debug message pops up when I select a range of cells and delete Brian Excel Programming 6 October 17th 04 12:55 AM
How do I select a whole range and delete the contents of the cells? benthomas_duck Excel Programming 2 June 4th 04 02:31 AM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"