ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting and cutting unknown picture numbers from a specifc range of cells (https://www.excelbanter.com/excel-programming/400197-selecting-cutting-unknown-picture-numbers-specifc-range-cells.html)

[email protected]

Selecting and cutting unknown picture numbers from a specifc range of cells
 
I have a range of cells B5:H5. Each has a different picture in it but
the picture numbers vary and change on a regular basis.

I need to write a macro that will select all seven pictures (1 per
cell) so I can cut or delete them. I can't say to select or cut a
specific picture number from the cell because as I said, they change
on regular basis and are not constant. The constant is the cell
reference. Any assistance is greatly appreciated.

Don


JE McGimpsey

Selecting and cutting unknown picture numbers from a specifc range of cells
 
Since pictures exist in the drawing layer, not in cells, you can't use
the cell references directly. However, if all your pictures fit *over*
(or in front of, depending on your perspective) those cells, this may
work:


Public Sub DeleteSomePictures()
Dim rDeleteCells As Range
Dim pic As Picture

Set rDeleteCells = Sheets("Sheet1").Range("B5:H5")
For Each pic In rDeleteCells.Parent.Pictures
With pic
If Not Intersect(.TopLeftCell, rDeleteCells) Is Nothing Then _
.Delete
End With
Next pic
End Sub



In article .com,
wrote:

I have a range of cells B5:H5. Each has a different picture in it but
the picture numbers vary and change on a regular basis.

I need to write a macro that will select all seven pictures (1 per
cell) so I can cut or delete them. I can't say to select or cut a
specific picture number from the cell because as I said, they change
on regular basis and are not constant. The constant is the cell
reference. Any assistance is greatly appreciated.

Don


[email protected]

Selecting and cutting unknown picture numbers from a specifc range of cells
 
On Oct 29, 11:21 am, JE McGimpsey wrote:
Since pictures exist in the drawing layer, not in cells, you can't use
the cell references directly. However, if all your pictures fit *over*
(or in front of, depending on your perspective) those cells, this may
work:

Public Sub DeleteSomePictures()
Dim rDeleteCells As Range
Dim pic As Picture

Set rDeleteCells = Sheets("Sheet1").Range("B5:H5")
For Each pic In rDeleteCells.Parent.Pictures
With pic
If Not Intersect(.TopLeftCell, rDeleteCells) Is Nothing Then _
.Delete
End With
Next pic
End Sub

In article .com,



wrote:
I have a range of cells B5:H5. Each has a different picture in it but
the picture numbers vary and change on a regular basis.


I need to write a macro that will select all seven pictures (1 per
cell) so I can cut or delete them. I can't say to select or cut a
specific picture number from the cell because as I said, they change
on regular basis and are not constant. The constant is the cell
reference. Any assistance is greatly appreciated.


Don- Hide quoted text -


- Show quoted text -


That worked great. Is there a way to select the seven pictures, again
not knowing the picture numbers and moving them to another cell?
Example, I have just used your last reference to clear the cell (or
layer) for cells (B5:H5). I know want to select the pictures from
(B13:H13) and move them from (B13:H13) to the now empty (B5:H5).

Thanks as always for your tremendous assistance.

Don


JE McGimpsey

Selecting and cutting unknown picture numbers from a specifc range of cells
 
One way:

Public Sub TransferSomePictures()
Dim pic As Picture
Dim rFrom As Range
Dim rTo As Range
Dim rCell As Range

With Sheets("Sheet1").Range("B13:H13")
For Each pic In .Parent.Pictures
If Not Intersect(pic.TopLeftCell, .Cells) Is Nothing Then _
pic.Top = .Offset(-8, 0).Top
Next pic
End With
End Sub


In article . com,
wrote:

That worked great. Is there a way to select the seven pictures, again
not knowing the picture numbers and moving them to another cell?
Example, I have just used your last reference to clear the cell (or
layer) for cells (B5:H5). I know want to select the pictures from
(B13:H13) and move them from (B13:H13) to the now empty (B5:H5).



All times are GMT +1. The time now is 02:05 AM.

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