![]() |
#2
|
|||
|
|||
![]()
Welcome to the forum!
Automatic would mean that the macros are in the workbook and can act due to some event. If you want to keep the macro in your open workbook or personal workbook, then it would be run manually. Since the height and widths have different ratios, did you really want to distort the image and make it fit? If you don't want to distort it, one would just set one of the dimensions. As for the image file's name, what is the file extension? gif, jpg, bmp, png, etc. It also makes a difference in coding if an image could already be in the image's cell. While one could overlay with another image, that is generally not done. So, more code is needed to avoid that problem. Here is a simple example that may suit with a tweak or two. Change the offset from 1 to the offset you want, 13. Code:
Sub Main() Dim pic As Shape, r As Range, fPath As String fPath = "x:\pics\" On Error Resume Next For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp)) Set pic = ActiveSheet.Shapes.AddPicture(Filename:=fPath & r.Value2 & ".jpg", _ LinkToFile:=msoFalse, SaveWithDocument:=msoCTrue, _ Left:=r.Offset(, 1).Left, Top:=r.Offset(, 1).Top, _ Width:=r.Width, Height:=r.RowHeight) 'Debug.Print pic.Name Next r End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
hysterical.useless | Drawing and Graphics | 8 | 01-30-2018 04:27 PM |
![]() |
macropodjr | Mail Merge | 5 | 09-11-2017 11:10 AM |
![]() |
ineedmacrohelp | Word VBA | 1 | 08-06-2015 06:46 AM |
![]() |
Yuffster | Word VBA | 2 | 01-30-2015 06:05 AM |
Macro to Insert Text Into Cells Having Multiple Lines | revans611 | Excel Programming | 4 | 10-24-2011 10:15 AM |