1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Adding multiple images to 1 cell

Hello.

I've found some code that reduces the image size for storing within a data sheet. I'm now trying to find a way, that once images are inserted via the button. They appear in specific cells, And not next to the marco button I created/assigned to this code.

Sub InsertMultipleImagesInCell() Dim PicList As Variant Dim img As Picture Dim TargetCell As Range Dim i As Integer Dim TopPos As Double, LeftPos As Double 'Set target cell (change as needed) Set TargetCell = ActiveCell 'Select multiple images PicList = Application.GetOpenFilename(FileFilter:="Pictures (*.jpg;*.png;*.bmp), *.jpg;*.png;*.bmp", MultiSelect:=True) If IsArray(PicList) Then TopPos = TargetCell.Top LeftPos = TargetCell.Left For i = LBound(PicList) To UBound(PicList) 'Insert image Set img = ActiveSheet.Pictures.Insert(PicList(i)) 'Resize and position image With img .ShapeRange.LockAspectRatio = msoTrue .Height = TargetCell.Height 'Fit height to cell .Top = TopPos .Left = LeftPos 'If stacked horizontally, update LeftPos LeftPos = LeftPos + .Width End With Next i End If End Sub Thanks in advanced Matt 
submitted by /u/MetaThw
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article