Question Locked

for Excel Macro

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want a macrD

Ex: I have One Folder in desktop " Design?, in this folder i have 5000 design Image in jpg Format with Sr no.
(a001,a002,a003,b001,b002,c001,c002,c003)

When I type whatever no in excel cell, I want this image in excel for selected cell automatically.

3 replies

by mark

try recording the manual process of inserting a picture to a cell and then edit the macro. you can paste the results so we can see what exactly you are doing and possibly automate it

by rob.atkinson01

You can use this macro to do what you need. Infortunately it's not going to magically put the pictures in the cell you want, instead you use input boxes. Still, simple enough.

Let me know if that helps.
Public Sub InsertPicture()
Dim SerialNumber As String
Dim ImagePath As String
Dim Column As Integer
Dim row As Integer

SerialNumber = InputBox("Please type the serial number of the desired image", "Define Serial Number", "a001")
Set Location = Application.InputBox(prompt:="Please select the desired cell in which to locate the image", Title:="Range Select", Type:=8)
row = Location.row
Column = Location.Column

'you must insert the username where it says USERNAME below

ImagePath = "C:\Documents and Settings\USERNAME\Desktop\Design\" & SerialNumber & ".jpg"
ActiveSheet.Cells(row, Column).Select
ActiveSheet.Pictures.Insert(ImagePath).Select

End Sub

Rob Atkinson

This discussion is closed to new replies.