[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 955
  • Last Modified:

Lock image to cell in Excel

I have a macro that will copy and past cells. In one of the cells there is an image that I want to move with the copy and paste. The text in the cells copies but the picture does not. Is there a way to embed the image in to the cell?
0
varesources
Asked:
varesources
  • 2
  • 2
1 Solution
 
byundtCommented:
Hello varesources,
If the image is mostly contained within the cell, it ought to move with the cell when you copy and paste. You need to choose one of the "Move with cell" options in the Format...Picture dialog (Properties tab) that you can see when you rightclick the picture.

If the image is quite large, you might consider placing it in a cell Comment. This will move with the cell when you copy and paste. It won't move when you sort the cells, however.
1) Insert...Comment
2) Rightclick on the border of the comment, and choose Format...Comment
3) On the Colors and Lines tab, click the arrow to the right of the Color selector in the Fill section
4) Choose Fill Effects from the resulting pop-up, then go to the Picture tab
5) Insert the desired picture
6) Size the Comment border to suit

Regards,

Brad
0
 
varesourcesAuthor Commented:
I am using 2007. Where is the comment in my version? When I manually copy and past the image will move but when my macro does it, it does not. I have attached my code.
Sheets("Rates").Visible = True
    Sheets("Rates").Select
    Range("L11:N11").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("D17:F17").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Range("I39").Select
    ActiveCell.FormulaR1C1 = "Added"
    Range("I39").Select

Open in new window

0
 
folderolCommented:
The picture won't move for you because you are using
 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

instead of just
  Selection.Paste

If you must use pastespecial, then you have to also copy the picture.

Tom.
Sheets("Rates").Visible = True 
    Sheets("Rates").Select 
    Range("L11:N11").Select 
    Selection.Copy 
    Sheets("Sheet2").Select 
    Range("D17:F17").Select 
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ 
        :=False, Transpose:=False 
    Sheets("Rates").Select 
    Sheets("Rates").Shapes("Picture 1").Copy
    Sheets("Sheet2").Select 
    Range("D17:F17").Select 
    Activesheet.Paste
    Sheets("Sheet1").Select 
    Application.CutCopyMode = False 
    Range("I39").Select 
    ActiveCell.FormulaR1C1 = "Added" 
    Range("I39").Select

Open in new window

0
 
varesourcesAuthor Commented:
I get a run time error with using Selection.Paste only.
0
 
folderolCommented:
Try Activesheet.Paste

Your current Selection at the line
Selection.Paste

is a cell, and you are not pasting a cell object.

Tom

by the way, I didn't get notified of your feedback, wonder what's up with that?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now