Private PxP, PyP
Private Declare Function GetDC& Lib "user32" (ByVal hWnd&)
Private Declare Function GetDeviceCaps& Lib "gdi32" (ByVal hdc&, ByVal nIndex&)
Function GetPPI(L&)
GetPPI = 72 / GetDeviceCaps(GetDC(0&), L&)
End Function
Function ShapeInMiddle$(Rg As Range)
Dim Obj As Object
If PxP = 0 Then PxP = GetPPI(88): PyP = GetPPI(90)
With ActiveWindow
Set Obj = .RangeFromPoint(.PointsToScreenPixelsX((Rg.Left + Rg.Width / 2) / PxP), .PointsToScreenPixelsY((Rg.Top + Rg.Height / 2) / PyP))
End With
If TypeName(Obj) <> "Range" Then ShapeInMiddle = Obj.Name
Set Obj = Nothing
End Function
Sub Demo()
With Cells(1).CurrentRegion.Columns
If .Count < 3 Then Beep: Exit Sub
VA = .Item(2).Value
End With
For R& = 2 To UBound(VA)
If VA(R, 1) > "" And ShapeInMiddle(Cells(R, 3)) = "" Then
Cells(R, 3).Select
With ActiveSheet.Shapes(ActiveSheet.Pictures.Insert(VA(R, 1)).Name)
.Width = ActiveCell.Width
If .Height > ActiveCell.Height Then .Height = ActiveCell.Height
.IncrementLeft (ActiveCell.Width - .Width) / 2
.IncrementTop (ActiveCell.Height - .Height) / 2
End With
End If
Next
End Sub