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()
MyUserForm.Show
End Sub

How to transfer pictures to image control on user form

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”)
Else
With NameFound
fPath = ThisWorkbook.Path & “\”
Image1.Picture = LoadPicture(fPath & “\” & TextBox1.Value & “.jpg”)
MsgBox (“Picture of “) & TextBox1.Value
End With
End If
End With
Next
End Sub
Private Sub CommandButton3_Click()
End
‘Remark: you can also write: Unload Me
End Sub
Note:

  • 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. tonygabani

    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.

    Reply
    1. Frankie

      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.

      Reply
  2. Chopa James

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

    Reply
  3. fut 12 coin generator

    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

    Reply
  4. 21st.com login

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

    Reply
  5. Garba Suleiman

    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

    Reply

Leave a Reply

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