p.h
p.h

Reputation: 11

Excel: create image from cell range

Using Excel VBA, I want to create an image showing the content of a cell.

Upvotes: 1

Views: 3495

Answers (2)

Tim Williams
Tim Williams

Reputation: 166885

Are you trying to get a "live" picture which is linked back to the source range, like using the Camera tool in Excel?

Sub Macro1()

    Dim s, rng As Range, rngDest As Range

    Set rng = ActiveSheet.Range("B2:C3")
    Set rngDest = ActiveSheet.Range("E10")

    rng.Copy
    With ActiveSheet.Pictures.Paste(link:=True)
        .Left = rngDest.Left
        .Top = rngDest.Top
    End With

End Sub

I don't think you can get around using copy/paste though.

Upvotes: 1

JNevill
JNevill

Reputation: 50308

Instead of copying the cell, then telling it you want to paste to another cell as a picture, try using:

Range("A1").CopyPicture Appearance:=xlScreen, Format:=xlPicture

Now A1 is in your clipboard as a picture. You can use boring old paste to stick it somewhere else.

Range("B1").Select
ActiveSheet.Paste

Upvotes: 1

Related Questions