Place Picture Excel Worksheet Range into User Form with VBA

We cannot place a picture of an Excel worksheet range directly as image into a user-form. First we create a picture of the required range either by using the simple copy-paste procedure or by taking a snapshot with the camera tool. This picture can now be placed into a chart area. We finally export the chart object as a GIF or JPG file which can be quickly and easily placed onto a user-form as shown in the training video below:


The complete VBA code to transfer a picture of an Excel worksheet range to a userform:

Private Sub CommandButton1_Click()

ActiveSheet.Pictures.Paste Link:=True
Application.CutCopyMode = False
Dim myChart As String, myPicture As String
Dim picWidth As Long, picHeight As Long

Application.ScreenUpdating = False

myPicture = Selection.Name
With Selection
picHeight = .ShapeRange.Height
picWidth = .ShapeRange.Width
End With

ActiveChart.Location Where:=xlLocationAsObject, Name:=”Sheet1″
Selection.Border.LineStyle = 0
myChart = Selection.Name & ” ” & Split(ActiveChart.Name, ” “)(2)

With ActiveSheet
With .Shapes(myChart)
.Width = picWidth
.Height = picHeight
End With


With ActiveChart
End With

.ChartObjects(1).Chart.Export Filename:=”C:\testfolder\MyPic.jpg”, FilterName:=”jpg”
End With

Application.ScreenUpdating = True

Set Picture = LoadPicture(“C:\testfolder\MyPic.jpg”)

End Sub

Further reading:

Enhance your Excel dashboard with the camera tool

Export pictures using Excel VBA

Pasting an image to a userform control

Split Function

Export Pictures from Excel

Load Picture Function