Put picture to column H by selecting row number from combobox list, and fit picture to cell with align to center point, saving aspectratio
Private Sub ComboBox1_Change()
PTstop = Me.ComboBox1.value
PicPath = Worksheets("Sheet1").Application.GetOpenFilename("*.jpg,*.png,*.jpeg,*.gif")
If PicPath <> False Then
With .Pictures.Insert(Filename:=PicPath)
With .ShapeRange
If .Width > .Height Then
If .Height >= Worksheets("Sheet1").Cells(PTstop, 8).Height Then
.Height = Worksheets("Sheet1").Cells(PTstop, 8).Height
If .Width >= Worksheets("Sheet1").Cells(PTstop, 8).Width Then
.Width = Worksheets("Sheet1").Cells(PTstop, 8).Width
Else
End If
Else
.Width = Worksheets("Sheet1").Cells(PTstop, 8).Width
If .Height >= Worksheets("Sheet1").Cells(PTstop, 8).Height Then
.Height = Worksheets("Sheet1").Cells(PTstop, 8).Height
Else
End If
End If
Else
.Height = Worksheets("Sheet1").Cells(PTstop , 8).Height
End If
.Top = Worksheets("Sheet1").Cells(PTstop, 8).Top + Worksheets("Sheet1").Cells(PTstop , 8).Height / 2 - .Height / 2
.Left = Worksheets("Sheet1").Cells(PTstop, 8).Left + Worksheets("Sheet1").Cells(PTstop, 8).Width / 2 - .Width / 2
End With
End With
End If
End Sub
Code to enlarge image then clicked to Right of Image, if click anywhere in column A, image should reduce in size. Not tested just as starting point.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rangeS As Range, picSelected As Shape, old
If Target.Column > 1 Then
Set rangeS = Target.Offset(, -1)
For Each picSelected In ActiveSheet.Shapes
If TypeName(picSelected.OLEFormat.Object) = "Picture" Then
If picSelected.TopLeftCell.Address = rangeS.Address Then
picSelected.Height = 250
picSelected.Width = 250
End If
End If
Next picSelected
ElseIf Target.Column = 1 Then
For Each picSelected In ActiveSheet.Shapes
If TypeName(picSelected.OLEFormat.Object) = "Picture" Then
With picSelected
If .Width > .Height Then
If .Height >= Target.Height Then
.Height = Target.Height
Else
.Width = Target.Width
If .Height >= Target.Height Then
.Height = Target.Height
Else
End If
End If
Else
.Height = Target.Height
End If
.Top = Target.Top + Target.Height / 2 - .Height / 2
.Left = Target.Left + Target.Width / 2 - .Width / 2
End With
End If
Next picSelected
End If
End Sub