Found this code from Barb Henderson.
Works great. However, I want to center the photo within the cell. I tried many different variations and it will not center in the cell, but in the middle of the entire sheet.
How to center the photo in the absolute middle of the cell and for photos to actually show when the excel file is viewed by others? Nobody can see the photos now because the path is on my computer.
Works great. However, I want to center the photo within the cell. I tried many different variations and it will not center in the cell, but in the middle of the entire sheet.
How to center the photo in the absolute middle of the cell and for photos to actually show when the excel file is viewed by others? Nobody can see the photos now because the path is on my computer.
VBA Code:
Sub Picture()
Dim pictname As String
Dim pastehere As Range
Dim pasterow As Long
Dim x As Long
Dim lastrow As Long
lastrow = Worksheets("sheet1").Range("B1").CurrentRegion.Rows.Count
x = 2
For x = 2 To lastrow
Set pastehere = Cells(x, 1)
pasterow = pastehere.Row
Cells(pasterow, 1).Select 'This is where picture will be inserted
pictname = Cells(x, 2) 'This is the picture name
ActiveSheet.Pictures.Insert("C:\Users\Barb\Pictures\demo\" & pictname & ".jpg").Select 'Path to where pictures are stored
With Selection
.Left = Cells(pasterow, 1).Left
.Top = Cells(pasterow, 1).Top
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 80#
.ShapeRange.Width = 80#
.ShapeRange.Rotation = 0#
End With
Next
End Sub