Excel Insert Picture To Cell & View Picture It's Original Size

%3CLINGO-SUB%20id%3D%22lingo-sub-2101118%22%20slang%3D%22en-US%22%3EExcel%20Insert%20Picture%20To%20Cell%20%26amp%3B%20View%20Picture%20It's%20Original%20Size%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2101118%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Insert-Image-To-Cell.gif%22%20style%3D%22width%3A%20981px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249742i1F0EB316F34E7C46%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Insert-Image-To-Cell.gif%22%20alt%3D%22Insert-Image-To-Cell.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20a%20template%20to%20insert%20a%20picture%20into%20another%20cell%20based%20on%20the%20text%20in%20the%20cell%20with%20VBA%20codes.%20Pictures%20are%20in%20the%20same%20folder%20as%20the%20workbook.%20The%20picture%20is%20fitted%20in%20the%20cell%20where%20it%20is%20inserted.When%20the%20added%20picture%20is%20clicked%2C%20it%20is%20displayed%20in%20its%20original%20size.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20the%20following%20codes%20can%20be%20entered%20to%20add%20the%20image%20that%20with%20the%20same%20name%20as%20the%20value%20of%20cell%20in%20column%20A%20to%20the%20cell%20in%20column%20D%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EActiveSheet.Pictures.Insert(ThisWorkbook.Path%20%26amp%3B%20%22%5C%22%20%26amp%3B%20Target.Value%20%26amp%3B%20%22.jpg%22).Select%0ASelection.Top%20%3D%20Target.Offset(0%2C%202).Top%0ASelection.Left%20%3D%20Target.Offset(0%2C%203).Left%0ASelection.ShapeRange.LockAspectRatio%20%3D%20msoFalse%0ASelection.ShapeRange.Height%20%3D%20Target.Offset(0%2C%202).Height%0ASelection.ShapeRange.Width%20%3D%20Target.Offset(0%2C%203).Width%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDetails%20and%20sample%20files%20at%20%3A%20%3CA%20href%3D%22https%3A%2F%2Feksi30.com%2Finsert-picture-in-cell-according-to-cell-value%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EExcel%20insert%20picture%20to%20cell%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2101118%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Insert-Image-To-Cell.gif

 

I created a template to insert a picture into another cell based on the text in the cell with VBA codes. Pictures are in the same folder as the workbook. The picture is fitted in the cell where it is inserted.When the added picture is clicked, it is displayed in its original size.

 

For example, the following codes can be entered to add the image that with the same name as the value of cell in column A to the cell in column D :

 

ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "\" & Target.Value & ".jpg").Select
Selection.Top = Target.Offset(0, 2).Top
Selection.Left = Target.Offset(0, 3).Left
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = Target.Offset(0, 2).Height
Selection.ShapeRange.Width = Target.Offset(0, 3).Width

 

Details and sample files at : Excel insert picture to cell

0 Replies