Insert picture in Excel from file in vba -
i insert picture in excel file depending on cell value. have set of pictures in file, each different name.
in excel, have table populated list of names, depending on criteria. list group of words same picture's names.
is there way through can upload pictures excel, when picture name appears in list?
thank you.
consider methodology.
sub insertpics() dim fpath string, fname string dim r range, rng range application.screenupdating = false fpath = "c:\users\public\pictures\sample pictures\" set rng = range("a1:a" & cells(rows.count, 1).end(xlup).row) = 1 each r in rng fname = dir(fpath) while fname <> "" if fname = r.value activesheet.pictures.insert(fpath & fname) .shaperange.lockaspectratio = msotrue set px = .shaperange if .shaperange.width > rows(i).columns(2).width .shaperange.width = columns(2).width cells(i, 2) px.top = .top px.left = .left .rowheight = px.height end end end if fname = dir loop = + 1 next r application.screenupdating = true end sub ' note: need file extension, such ',jpg', or whatever using, can match on that.
Comments
Post a Comment