In this article, you will learn about two easy methods for how to paste an image into an Excel cell from the clipboard. We will be using the Microsoft 365 version. However, you can use any version of Microsoft Excel and follow this tutorial.
Paste Image into Excel Cell from Clipboard: 2 Handy Approaches
There will be two simple methods to paste an image into an Excel cell from the clipboard. Firstly, we will use the keyboard shortcut to paste the image into the sheet. After that, we will use the Format Picture feature to paste and lock that image into a cell. Secondly, we will copy an image from an Excel sheet. This will put that image on the clipboard, and then we will use a VBA Macro to paste that image into an Excel cell.
1. Using Keyboard Shortcut
In this first method, we will use the keyboard shortcut to paste an image from the clipboard. After that, we will use the Size & Properties feature from the Format Picture option to paste that image into the Excel cell.
Steps:
- Firstly, you can see the blank cells where we will paste the image from the clipboard. Additionally, we have resized the cell size to fit the images better.
- You need to copy an image and it will be kept in the clipboard. We opened our image in the Microsoft Paint application and copied that image.
- Next, press Ctrl+V to paste that image into the Excel sheet.
- After that, you should resize the image if it is too large or too small.
- Afterward, move that image into cell C5.
- Then, right-click on that image and click on Format Picture….
- Hence, a dialog box will pop up.
- Then, select Size & Properties.
- After that, select “Move and size with cells” from the Properties section.
- By doing so, whenever we resize the cells the image will resize too. The following animated image shows that.
- Lastly, repeat this process for the rest of the cells and the final step should look like this.
2. Applying VBA to Paste Image into Excel Cell
We will apply a VBA code to paste an image into the Excel cell. Firstly, we will show you how to bring up the Module window, and then we will type the code. After that, we will copy an image from a sheet and it will be on the clipboard. Then, we will execute that code to achieve our objective.
Steps:
- To begin with, press ALT+F11 to bring up the VBA window.
- Then, from the Insert tab, select Module.
- Thirdly, type the following code in that window.
Option Explicit
Sub Paste_Image_from_Clipboard()
Dim Our_Object As New MSForms.DataObject
Dim Our_Clipboard_Data As MSForms.DataObject
Our_Object.GetFromClipboard
On Error GoTo Error_Solution
Our_Clipboard_Data = Our_Object.GetText
On Error GoTo 0
Error_Solution:
If Err = -2147221404 Then
Err = 0
Sheet2.Paste Destination:=Sheet2.Range("C7"), Link:=False
Else
'Do Nothing for This
End If
Call Align_Images
End Sub
Private Sub Align_Images()
Dim xShape As Shape
For Each xShape In ActiveSheet.Shapes
If xShape.Type = msoPicture _
And Not Intersect(xShape.TopLeftCell, _
ActiveSheet.Range("C5:C10")) Is Nothing Then
With xShape
.Top = .TopLeftCell.Top + (.TopLeftCell.Height - .Height) / 2
.Left = .TopLeftCell.Left + (.TopLeftCell.Width - .Width) / 2
End With
End If
Next
End Sub
VBA Code Breakdown
Option Explicit
Sub Paste_Image_from_Clipboard()
Dim Our_Object As New MSForms.DataObject
Dim Our_Clipboard_Data As MSForms.DataObject
- Firstly, we are calling our Subroutine “Paste_Image_from_Clipboard” and declaring the variable types.
Our_Object.GetFromClipboard
On Error GoTo Error_Solution
Our_Clipboard_Data = Our_Object.GetText
On Error GoTo 0
- Secondly, we are retrieving the clipboard image data and setting the error handler.
Error_Solution:
If Err = -2147221404 Then
Err = 0
Sheet2.Paste Destination:=Sheet2.Range("C7"), Link:=False
Else
'Do Nothing for This
End If
- We neglect the errors. Moreover, we set the output cell range as C7.
Call Align_Images
End Sub
- Thirdly, we are calling another Subroutine “Align_Images”, which will align the images and end this Subroutine.
Private Sub Align_Images()
Dim xShape As Shape
- After that, we create another Subroutine and set its variable type. Here, we have created this as a private sub because we will execute this Subroutine only from the first Sub.
For Each xShape In ActiveSheet.Shapes
If xShape.Type = msoPicture _
And Not Intersect(xShape.TopLeftCell, _
ActiveSheet.Range("C5:C10")) Is Nothing Then
With xShape
.Top = .TopLeftCell.Top + (.TopLeftCell.Height - .Height) / 2
.Left = .TopLeftCell.Left + (.TopLeftCell.Width - .Width) / 2
End With
End If
Next
End Sub
- Then, we create a For Each Next loop to go through the shapes from the clipboard. We resize the shapes using the With statement. Finally, we end this Subroutine.
- After that, copy this image from the sheet by pressing Ctrl+C.
- Then, press Alt+F8 to bring up the Macro window.
- Afterward, press Run.
- Then, it will execute the code and we will see the image in cell C7. Thus, we have shown you yet another way to paste an image into an Excel cell from the clipboard.
An Easy Way to Insert Picture in Excel Cell Background
In this section, we will discuss how to insert a picture into the Excel cell background. We will set the background image and it will show up in every cell in Excel. However, you can also insert separate pictures for individual cells. Now, let us show you how to insert a picture as the cell background.
Steps:
- Firstly, from the Page Layout tab, select Background.
- So, the Insert Pictures dialog box will appear.
- Secondly, select From a file.
- Then, another window will pop up.
- Thirdly, navigate to your picture directory.
- Afterward, select the image. We have selected the “Tree.png” image.
- Finally, press Insert.
- Therefore, we will see there is a picture background in the Excel file.
Things to Remember
You cannot directly paste an image into an Excel cell from the clipboard. You need to paste it in the Excel sheet first. Then, you will be able to paste it into a cell. This is a limitation in Excel. Therefore, we have shown you this way to complete the task.
Download Practice Workbook
You can download the Excel file from the link below.
Conclusion
We have shown you two easy methods for how to paste an image into an Excel cell from the clipboard. If you face any problems regarding these methods or have any feedback for me, feel free to comment below.
However, remember that our website implements comment moderation. Therefore, your comments may not be instantly visible. So, have a little bit of patience, and we will solve your query as soon as possible.
Related Articles
<< Go Back to Copy Paste in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!