Populate Image Control on User Form with Pictures from Worksheet Data Using VBA

How to transfer pictures from Excel worksheet data to a user form image control using VBA

  1. Create an Excel file with names. You can also add other details like address, phon numbers, etc.
  2. Now place all the images and the Excel file in the same folder
  3. In the Excel worksheet with the data place a command button whick on click will open a user form to which you wish to transfer the data including images to an image control

Private Sub CommandButton1_Click()
End Sub

Screen shot: Using data on Excel worksheets to transfer pictures to an image control on user form

When you click on the command button ‘show form’ a user-form appears. The detailed code of each item on the user form is shown below:
Private Sub CommandButton1_Click()
Dim NameFound As Range
Dim fPath As String
Row = 2
For Row = Row To 11
With Cells(Row, 1)
TextBox1.Text = Cells(Row, 1)
Set NameFound = .Find(TextBox1.Value)
If NameFound Is Nothing Then
Image1.Picture = LoadPicture(fPath & “nopic.gif”)
With NameFound
fPath = ThisWorkbook.Path & “\”
Image1.Picture = LoadPicture(fPath & “\” & TextBox1.Value & “.jpg”)
MsgBox (“Picture of “) & TextBox1.Value
End With
End If
End With
End Sub
Private Sub CommandButton3_Click()
‘Remark: you can also write: Unload Me
End Sub

  • Keep the Excel file and the image file in the same folder.
  • Name the images so that the names for the images and the names entered in the Excel worksheet match.

Watch the video below:

Further reading: Load Worksheet Picture Into UserForm Image Control

7 thoughts on “Populate Image Control on User Form with Pictures from Worksheet Data Using VBA

  1. Sir, through the user form I had created, I can add or Edit data into excel worksheet, I also have an image control on my user form on which I can upload any Image from my computer at run time. My problem is I find it difficult to add / Edit the image to excel work sheet. is this task possible, sir, your assistant will be of great help.

    1. Thanks for your post. One other thing is when you are selling your property on your own, one of the challenges you need to be alert to upfront is how to deal with house inspection records. As a FSBO owner, the key concerning successfully transferring your property plus saving money upon real estate agent profits is untdnsearding. The more you realize, the easier your property sales effort will likely be. One area in which this is particularly essential is inspection reports.

  2. How to autoprint data in an excel vba worksheet upon loading it from a userform. Please give help me with the code

  3. In fact, V guvax jr fubhyq jnvg hagvy Zbaqnl sbe nal tvs cnegl, obbx be zbivr. Vs Znex frrf gur raguhfvnfz ur jvyy creuncf thrff gung ur vfa'g fbzr rivy qhqr jub'f tbvat gb uheg gur uboovgf onqyl naq gel sbe gur Evat – jr ernyyl qba'g xabj zhpu nobhg uvz ol gung cbvag. Well that's my humble opinion anyway

  4. …… shit.真係鬼掩眼,”change request *review* period” … 竟然看漏了 “review” 一字。多謝閣下提點。依我看,即使是最低限度的更改(即是把語言名稱從 “Yue” 改為 “Yuet”)也很難獲接納;即使變得了,也有點阿 Q。真是有點意興闌珊。

  5. How can i upload and retrieve multiple files/images attached to an individual using an ID as a key and as well give each file/image a separate name so as to be able to retrieve it individually but all the files/images belong to an individual

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.