Hello friends, Today i'm going to share some MS Excel's features using VBA codes:
In daily office work most of the people facing problems with inserting multiple pictures/images in a single row/column or cell by cell with predefined image size and shape, so here is the solution:
Its very easy no need to be panic:
First thing first:
1. Open Ms Excel.
2. Define the size of the cell by selecting the cells and dragging down:
3. Select the Row or Column; wherever you want to insert the multiple pictures.
4. Now press ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
5. Click Insert and then Module, and paste the following macro in the Module Window.
Sub InsertPictures()
'Update 20140513
Dim PicList() As Variant
Dim PicFormat As String
Dim Rng As Range
Dim sShape As Shape
On Error Resume Next
PicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)
xColIndex = Application.ActiveCell.Column
If IsArray(PicList) Then
xRowIndex = Application.ActiveCell.Row
For lLoop = LBound(PicList) To UBound(PicList)
Set Rng = Cells(xRowIndex, xColIndex)
Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
xRowIndex = xRowIndex + 1
Next
End If
End Sub
6. Then press the F5 key to run the code. Automatically window will appear to select the pictures. Select all pictures:
7. Finally just press Open n see all your images/pictures are organized:
Done.
If You Like It Share It: